[android-developers] Re: How to start an activity from a service
startActivity works the same in a service as it does in an activity (Context vs. Activity argument not withstanding), and I don't think it's gauche to launch an activity from your service. In many cases, you need to launch an activity from a service when it needs attention. Doug -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an activity from a service
would you be able to use the NotificationManager and let the user start the activity? if possible that might be less intrusive... On Wed, Oct 6, 2010 at 2:23 AM, Doug beafd...@gmail.com wrote: startActivity works the same in a service as it does in an activity (Context vs. Activity argument not withstanding), and I don't think it's gauche to launch an activity from your service. In many cases, you need to launch an activity from a service when it needs attention. Doug -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an activity from a service
I might be bad manners to start an Activity out of the blue like that, but here's how you do it: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass( myContext , ActivityToLaunch.class ); startActivity( intent ); Note that the first arg of setClass is normally an Activity context. I've never tried it with a Service context but it might work. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an activity from the Service
On 3 Sep, 00:31, Prateek finch...@gmail.com wrote: i have tried intent but doesnot seems to get though it . Then you're not using the Intent correctly, because that is the correct approach. Intents can be finicky beasts, requiring several pieces to all be correct before they'll do what you want. And before you ask - because there are so many subtleties, one person's code sample often won't work for another person. Keep at it, maybe refer to an Android book if you get stuck, but you are on the right track. String -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an activity from the Service
Use an intent with a set component. You need flag LAUNCHED_FROM_BACKGROUND or whatever it is and NEW_TASK if I remember right. Look in the log and see what the problem is. Pent On Sep 3, 8:31 am, Prateek finch...@gmail.com wrote: i have a launcher activity which gets activated everytime i start the application and a service which complements it. Now as i press the return key from my main activity .Its Ondestroy gets called.Now i have nullify the pointer of the my launcher activity there. now i am listening through the service any event happening on the network after closing the launcher activity thread and if any event occurs i have to relaunch my launcher activity. i have tried intent but doesnot seems to get though it . -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an activity from the Service
I think just FLAG_ACTIVITY_NEW_TASK would work.. On Sep 3, 2:59 pm, Pent tas...@dinglisch.net wrote: Use an intent with a set component. You need flag LAUNCHED_FROM_BACKGROUND or whatever it is and NEW_TASK if I remember right. Look in the log and see what the problem is. Pent On Sep 3, 8:31 am, Prateek finch...@gmail.com wrote: i have a launcher activity which gets activated everytime i start the application and a service which complements it. Now as i press the return key from my main activity .Its Ondestroy gets called.Now i have nullify the pointer of the my launcher activity there. now i am listening through the service any event happening on the network after closing the launcher activity thread and if any event occurs i have to relaunch my launcher activity. i have tried intent but doesnot seems to get though it . -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an Activity from a Service and getting a result from it
Sorry about resurrecting an old thread, but really? All resources from all APK's are public to all APK's at all times? Could yall post a new blog post about how to write secure Android applications? ;) How about assets? And whats the deal with the stuff that ends up in your assets folder that you didn't put there? On Feb 16, 2:04 pm, Dianne Hackborn hack...@android.com wrote: On Mon, Feb 15, 2010 at 4:37 PM, jotobjects jotobje...@gmail.com wrote: Are the resources of the another application package essentially public - can any application call Context.createPackageContext() to get the context of a different application? Yep all resources are public. This allows other applications to display your icons and labels (such as when you appear in a picker), inflate your layout for app widgets, etc. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
On Fri, Mar 26, 2010 at 4:22 PM, Matt Kanninen mathias...@gmail.com wrote: Sorry about resurrecting an old thread, but really? All resources from all APK's are public to all APK's at all times? Yes. Could yall post a new blog post about how to write secure Android applications? ;) One possibility is to use encryption of things you want to protect. How about assets? And whats the deal with the stuff that ends up in your assets folder that you didn't put there? You mean if you look at the contents of the AssetManager? Those are in the framework. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[android-developers] Re: How to start an Activity from a Service and getting a result from it
On Feb 15, 5:01 pm, Mark Murphy mmur...@commonsware.com wrote: jotobjects wrote: Are the resources of the another application package essentially public - can any application call Context.createPackageContext() to get the context of a different application? Yes. It shocked the heck out of me when I realized it. It's possible there are some limits, but I'm not aware of any. Getting resources is just the start. For instance with a Context you can get lists of databases and files and delete them! Seems a little extreme for another package to be able to do that :) Hopefully it's not possible. Even getting the names of files is potentially a security issue. Getting access to MetaData via PackageManager seems reasonable if you are aware that this is how it works, but the rationale for getting the Context of another package is not so clear - do you understand the purpose? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
jotobjects wrote: For instance with a Context you can get lists of databases and files and delete them! No, you can't. Linux file permissions will prevent this. Getting access to MetaData via PackageManager seems reasonable if you are aware that this is how it works, but the rationale for getting the Context of another package is not so clear - do you understand the purpose? In part, it's so you can get at the icons and names in order to present Intents (e.g., home screen launcher). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
On Mon, Feb 15, 2010 at 4:37 PM, jotobjects jotobje...@gmail.com wrote: Are the resources of the another application package essentially public - can any application call Context.createPackageContext() to get the context of a different application? Yep all resources are public. This allows other applications to display your icons and labels (such as when you appear in a picker), inflate your layout for app widgets, etc. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
download free important softwares,movies,games many more http://www.moreutilities.blogspot.com/ On Sat, Feb 13, 2010 at 11:59 PM, Menny menn...@gmail.com wrote: So you suggest that I'll have a pre-define resource which will hold all the information I need (let's say it is an XML resource) for creating the external keyboard. This sounds OK. The only problem is how to query for packages which have this resource? I can still create an Activity which have another pre-defined activity- filter which I can query for. Is this a reasonable method? Or is there a clearer way (I mean, I create an activity just for query usages)? Thanks, Menny On Feb 14, 12:44 am, Mark Murphy mmur...@commonsware.com wrote: Menny wrote: I don't know what the other ContentProviders URI are. They can be anything, I want to release my keyboard service, and then release layouts as I need. This means that, somehow, the keyboard service needs to know which layout packages are installed on the device, and what are the URI of their content-providers. Another alternative is to still use Context.createPackageContext(), but primarily as a bootstrap. The APK would publish its content URI in a pre-determined resource (e.g., R.string.any_soft_keyboard_provider_uri), which you would then use. -- Mark Murphy (a Commons Guy)http://commonsware.com| http://twitter.com/commonsguy Android Development Wiki:http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an Activity from a Service and getting a result from it
On Feb 13, 11:36 am, Dianne Hackborn hack...@android.com wrote: This sounds much more complicated than you need. If you just want to load resources from another .apk, you don't need any code in it at all -- just use Context.createPackageContext() to get the context for the other package and load its resources from there. Are the resources of the another application package essentially public - can any application call Context.createPackageContext() to get the context of a different application? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
jotobjects wrote: Are the resources of the another application package essentially public - can any application call Context.createPackageContext() to get the context of a different application? Yes. It shocked the heck out of me when I realized it. It's possible there are some limits, but I'm not aware of any. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
You can follow the same model we use for input methods, app widgets, live wallpapers, and other things (none of which are fundamentally kinds of things in the platform, but built on top of the fundamental generic activity, receiver, service, and provider components): 1. Pick the kind of component that best represents your object. If there is not going to be any code that needs to be run by the object, then this is kind-of arbitrary. The two most typical components to use for this are a receive or service. Let's pick a receiver. 2. Define your own action the you can use to find any receivers you are interested in. For example com.mydomain.keyapp.EXTERNAL_KEYBOARD. 4. Define a meta-data item to be associated with this component. This will be a reference to an XML resource, containing an XML file organized however you want describing your domain-specific information associated with the component. 3. When you run, use PackageManager,queryIntentReceivers() to find all receiver that support your protocol. Use GET_META_DATA to also retrieve the meta-data associate with the component. You can iterate through the returned list, processing the XML meta data file associated with each of the returned components to find out about them. You can look at WallpaperService for a pretty good example of a typical way to structure such a thing (though in this case based on a service, not a receiver): http://developer.android.com/reference/android/service/wallpaper/WallpaperService.html http://developer.android.com/reference/android/service/wallpaper/WallpaperService.htmlNote the SERVICE_INTERACE (that's the action) and SERVICE_META_DATA associated with the component. The WallpaperInfo class is a good example of how you can parse the component and meta-data associated with it: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/app/WallpaperInfo.javahttp://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/app/WallpaperInfo.java;h=34d3133bdf05e89eb15e2dafdec22040d2decbec;hb=HEAD (Note because we do not currently support third party shared libraries, you will not be able to define your own custom attributes that can be used by the other applications. You can use any of the standard platform attributes, though, and just retrieve regular attributes of whatever type you want.) On Sat, Feb 13, 2010 at 11:59 PM, Menny menn...@gmail.com wrote: So you suggest that I'll have a pre-define resource which will hold all the information I need (let's say it is an XML resource) for creating the external keyboard. This sounds OK. The only problem is how to query for packages which have this resource? I can still create an Activity which have another pre-defined activity- filter which I can query for. Is this a reasonable method? Or is there a clearer way (I mean, I create an activity just for query usages)? Thanks, Menny On Feb 14, 12:44 am, Mark Murphy mmur...@commonsware.com wrote: Menny wrote: I don't know what the other ContentProviders URI are. They can be anything, I want to release my keyboard service, and then release layouts as I need. This means that, somehow, the keyboard service needs to know which layout packages are installed on the device, and what are the URI of their content-providers. Another alternative is to still use Context.createPackageContext(), but primarily as a bootstrap. The APK would publish its content URI in a pre-determined resource (e.g., R.string.any_soft_keyboard_provider_uri), which you would then use. -- Mark Murphy (a Commons Guy)http://commonsware.com| http://twitter.com/commonsguy Android Development Wiki:http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an Activity from a Service and getting a result from it
I'll look at the examples, and try that. Thanks. On Feb 14, 11:07 am, Dianne Hackborn hack...@android.com wrote: You can follow the same model we use for input methods, app widgets, live wallpapers, and other things (none of which are fundamentally kinds of things in the platform, but built on top of the fundamental generic activity, receiver, service, and provider components): 1. Pick the kind of component that best represents your object. If there is not going to be any code that needs to be run by the object, then this is kind-of arbitrary. The two most typical components to use for this are a receive or service. Let's pick a receiver. 2. Define your own action the you can use to find any receivers you are interested in. For example com.mydomain.keyapp.EXTERNAL_KEYBOARD. 4. Define a meta-data item to be associated with this component. This will be a reference to an XML resource, containing an XML file organized however you want describing your domain-specific information associated with the component. 3. When you run, use PackageManager,queryIntentReceivers() to find all receiver that support your protocol. Use GET_META_DATA to also retrieve the meta-data associate with the component. You can iterate through the returned list, processing the XML meta data file associated with each of the returned components to find out about them. You can look at WallpaperService for a pretty good example of a typical way to structure such a thing (though in this case based on a service, not a receiver): http://developer.android.com/reference/android/service/wallpaper/Wall... http://developer.android.com/reference/android/service/wallpaper/Wall...Note the SERVICE_INTERACE (that's the action) and SERVICE_META_DATA associated with the component. The WallpaperInfo class is a good example of how you can parse the component and meta-data associated with it: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;... (Note because we do not currently support third party shared libraries, you will not be able to define your own custom attributes that can be used by the other applications. You can use any of the standard platform attributes, though, and just retrieve regular attributes of whatever type you want.) On Sat, Feb 13, 2010 at 11:59 PM, Menny menn...@gmail.com wrote: So you suggest that I'll have a pre-define resource which will hold all the information I need (let's say it is an XML resource) for creating the external keyboard. This sounds OK. The only problem is how to query for packages which have this resource? I can still create an Activity which have another pre-defined activity- filter which I can query for. Is this a reasonable method? Or is there a clearer way (I mean, I create an activity just for query usages)? Thanks, Menny On Feb 14, 12:44 am, Mark Murphy mmur...@commonsware.com wrote: Menny wrote: I don't know what the other ContentProviders URI are. They can be anything, I want to release my keyboard service, and then release layouts as I need. This means that, somehow, the keyboard service needs to know which layout packages are installed on the device, and what are the URI of their content-providers. Another alternative is to still use Context.createPackageContext(), but primarily as a bootstrap. The APK would publish its content URI in a pre-determined resource (e.g., R.string.any_soft_keyboard_provider_uri), which you would then use. -- Mark Murphy (a Commons Guy)http://commonsware.com| http://twitter.com/commonsguy Android Development Wiki:http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
Menny wrote: So you suggest that I'll have a pre-define resource which will hold all the information I need (let's say it is an XML resource) for creating the external keyboard. This sounds OK. The only problem is how to query for packages which have this resource? I'm not sure if there is an efficient query-for-resource mechanism. I can still create an Activity which have another pre-defined activity- filter which I can query for. It doesn't necessarily have to be a filter on an activity, but, yes, that should be a time-efficient lookup method. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Training in US: 8-12 February 2010: http://bignerdranch.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
OK, thanks. I'll try that. On Sun, Feb 14, 2010 at 14:15, Mark Murphy mmur...@commonsware.com wrote: Menny wrote: So you suggest that I'll have a pre-define resource which will hold all the information I need (let's say it is an XML resource) for creating the external keyboard. This sounds OK. The only problem is how to query for packages which have this resource? I'm not sure if there is an efficient query-for-resource mechanism. I can still create an Activity which have another pre-defined activity- filter which I can query for. It doesn't necessarily have to be a filter on an activity, but, yes, that should be a time-efficient lookup method. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Training in US: 8-12 February 2010: http://bignerdranch.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
Menny Even Danan wrote: OK, thanks. I'll try that. Actually, I hadn't seen Ms. Hackborn's response before replying -- definitely consider following her guidance in this area. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Consulting/App Development: http://commonsware.com/consulting -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an Activity from a Service and getting a result from it
OK. I'll be explain my needs: I'm the author of AnySoftKeyboard (http:// softkeyboard.googlecode.com). The reason I made this keyboard, is to provide alternative layouts in the on-screen keyboard (e.g., Hebrew, Russian, DVORAK, etc. and of course, qwerty). But the keyboard APK gets bloated with all the layouts, and dictionaries etc So, I wanted to move all layouts to external packages: one layout (or several) per package. All the data I need to create a layout are the resource IDs of the layout, the dictionary and several other stuff, all of which can be retrieved using a ContentProvider. But I need the ContentProvider's URI. So I thought that starting an Activity and getting a result from it (startActivityForResult call) will be perfect for me. I do not need any UI to popuup (actually, I prefer that none will), I get need to get some data from the external package. So, these are my needs. Anyone can suggest a way? Thanks, Menny On Feb 12, 10:35 am, Kevin Duffey andjar...@gmail.com wrote: The whole purpose of a service is to stay in the background doing something, so not sure why you would want to display a UI in a non-UI based app. As Dianne said, post a notification that shows up on the status bar... when the user slides it down and clicks on it, that can launch an activity... which can then bind to the service to pass it info if need be. I'd still argue that would not be a good idea either. Can you elaborate on why you need some user interaction with your service.. is it something that can't be, perhaps set in a user preferences within an activity that the user launches the first time (or later to change settings)? On Thu, Feb 11, 2010 at 7:53 PM, Dianne Hackborn hack...@android.comwrote: You can't do this, nor should you. This would pop your UI in front of the user, disrupting whatever they are doing. This is highly discouraged. The proper way to do this is to post a notification, which the user can respond to when desired and can cause your own activity to be launched, which can then launch the other activity. On Thu, Feb 11, 2010 at 11:17 AM, Menny menn...@gmail.com wrote: Hi, I have a Service which needs to receive data from external packages. So, to locate the data providing external packages, I use activity- filter and PackageManager.queryIntentActivities function to locate the interesting packages. Now, from each such package, I need to get a ContentProvider URI. So I want to start the external Activity and the external activity will return a result to my service - something like startActivityForResult. The problem is that there is no way to call startActivityForResult from a Service, only Activity can do that, and my project does not have any Activity, and probably can't show UI for the user. The bottom line: Can anyone suggest a way to get ContentProvider URI from an external package, while my package has only a Service? Thanks, Menny. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
This sounds much more complicated than you need. If you just want to load resources from another .apk, you don't need any code in it at all -- just use Context.createPackageContext() to get the context for the other package and load its resources from there. And if you don't need any UI, and really do need to execute code in the other .apk, then you said you already have a content provider so why not just call that? Or a broadcast receiver? Or a service? Also if you really do need to run the code in the other .apk, please consider using android:sharedUserId with all of your .apks and having them all run in the same process, so you don't need to spin up multiple processes. On Sat, Feb 13, 2010 at 8:06 AM, Menny menn...@gmail.com wrote: OK. I'll be explain my needs: I'm the author of AnySoftKeyboard (http:// softkeyboard.googlecode.com). The reason I made this keyboard, is to provide alternative layouts in the on-screen keyboard (e.g., Hebrew, Russian, DVORAK, etc. and of course, qwerty). But the keyboard APK gets bloated with all the layouts, and dictionaries etc So, I wanted to move all layouts to external packages: one layout (or several) per package. All the data I need to create a layout are the resource IDs of the layout, the dictionary and several other stuff, all of which can be retrieved using a ContentProvider. But I need the ContentProvider's URI. So I thought that starting an Activity and getting a result from it (startActivityForResult call) will be perfect for me. I do not need any UI to popuup (actually, I prefer that none will), I get need to get some data from the external package. So, these are my needs. Anyone can suggest a way? Thanks, Menny On Feb 12, 10:35 am, Kevin Duffey andjar...@gmail.com wrote: The whole purpose of a service is to stay in the background doing something, so not sure why you would want to display a UI in a non-UI based app. As Dianne said, post a notification that shows up on the status bar... when the user slides it down and clicks on it, that can launch an activity... which can then bind to the service to pass it info if need be. I'd still argue that would not be a good idea either. Can you elaborate on why you need some user interaction with your service.. is it something that can't be, perhaps set in a user preferences within an activity that the user launches the first time (or later to change settings)? On Thu, Feb 11, 2010 at 7:53 PM, Dianne Hackborn hack...@android.com wrote: You can't do this, nor should you. This would pop your UI in front of the user, disrupting whatever they are doing. This is highly discouraged. The proper way to do this is to post a notification, which the user can respond to when desired and can cause your own activity to be launched, which can then launch the other activity. On Thu, Feb 11, 2010 at 11:17 AM, Menny menn...@gmail.com wrote: Hi, I have a Service which needs to receive data from external packages. So, to locate the data providing external packages, I use activity- filter and PackageManager.queryIntentActivities function to locate the interesting packages. Now, from each such package, I need to get a ContentProvider URI. So I want to start the external Activity and the external activity will return a result to my service - something like startActivityForResult. The problem is that there is no way to call startActivityForResult from a Service, only Activity can do that, and my project does not have any Activity, and probably can't show UI for the user. The bottom line: Can anyone suggest a way to get ContentProvider URI from an external package, while my package has only a Service? Thanks, Menny. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to
[android-developers] Re: How to start an Activity from a Service and getting a result from it
I don't know what the other ContentProviders URI are. They can be anything, I want to release my keyboard service, and then release layouts as I need. This means that, somehow, the keyboard service needs to know which layout packages are installed on the device, and what are the URI of their content-providers. I don't want to use sharedUserId, since I want to give other developers the option to create their own layouts. On Feb 13, 9:36 pm, Dianne Hackborn hack...@android.com wrote: This sounds much more complicated than you need. If you just want to load resources from another .apk, you don't need any code in it at all -- just use Context.createPackageContext() to get the context for the other package and load its resources from there. And if you don't need any UI, and really do need to execute code in the other .apk, then you said you already have a content provider so why not just call that? Or a broadcast receiver? Or a service? Also if you really do need to run the code in the other .apk, please consider using android:sharedUserId with all of your .apks and having them all run in the same process, so you don't need to spin up multiple processes. On Sat, Feb 13, 2010 at 8:06 AM, Menny menn...@gmail.com wrote: OK. I'll be explain my needs: I'm the author of AnySoftKeyboard (http:// softkeyboard.googlecode.com). The reason I made this keyboard, is to provide alternative layouts in the on-screen keyboard (e.g., Hebrew, Russian, DVORAK, etc. and of course, qwerty). But the keyboard APK gets bloated with all the layouts, and dictionaries etc So, I wanted to move all layouts to external packages: one layout (or several) per package. All the data I need to create a layout are the resource IDs of the layout, the dictionary and several other stuff, all of which can be retrieved using a ContentProvider. But I need the ContentProvider's URI. So I thought that starting an Activity and getting a result from it (startActivityForResult call) will be perfect for me. I do not need any UI to popuup (actually, I prefer that none will), I get need to get some data from the external package. So, these are my needs. Anyone can suggest a way? Thanks, Menny On Feb 12, 10:35 am, Kevin Duffey andjar...@gmail.com wrote: The whole purpose of a service is to stay in the background doing something, so not sure why you would want to display a UI in a non-UI based app. As Dianne said, post a notification that shows up on the status bar... when the user slides it down and clicks on it, that can launch an activity... which can then bind to the service to pass it info if need be. I'd still argue that would not be a good idea either. Can you elaborate on why you need some user interaction with your service.. is it something that can't be, perhaps set in a user preferences within an activity that the user launches the first time (or later to change settings)? On Thu, Feb 11, 2010 at 7:53 PM, Dianne Hackborn hack...@android.com wrote: You can't do this, nor should you. This would pop your UI in front of the user, disrupting whatever they are doing. This is highly discouraged. The proper way to do this is to post a notification, which the user can respond to when desired and can cause your own activity to be launched, which can then launch the other activity. On Thu, Feb 11, 2010 at 11:17 AM, Menny menn...@gmail.com wrote: Hi, I have a Service which needs to receive data from external packages. So, to locate the data providing external packages, I use activity- filter and PackageManager.queryIntentActivities function to locate the interesting packages. Now, from each such package, I need to get a ContentProvider URI. So I want to start the external Activity and the external activity will return a result to my service - something like startActivityForResult. The problem is that there is no way to call startActivityForResult from a Service, only Activity can do that, and my project does not have any Activity, and probably can't show UI for the user. The bottom line: Can anyone suggest a way to get ContentProvider URI from an external package, while my package has only a Service? Thanks, Menny. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
Menny wrote: I don't know what the other ContentProviders URI are. Then don't use a ContentProvider. Follow Ms. Hackborn's directions instead and use Context.createPackageContext() and access the other APKs' resources that way. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Training in US: 8-12 February 2010: http://bignerdranch.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to start an Activity from a Service and getting a result from it
Menny wrote: I don't know what the other ContentProviders URI are. They can be anything, I want to release my keyboard service, and then release layouts as I need. This means that, somehow, the keyboard service needs to know which layout packages are installed on the device, and what are the URI of their content-providers. Another alternative is to still use Context.createPackageContext(), but primarily as a bootstrap. The APK would publish its content URI in a pre-determined resource (e.g., R.string.any_soft_keyboard_provider_uri), which you would then use. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to start an Activity from a Service and getting a result from it
So you suggest that I'll have a pre-define resource which will hold all the information I need (let's say it is an XML resource) for creating the external keyboard. This sounds OK. The only problem is how to query for packages which have this resource? I can still create an Activity which have another pre-defined activity- filter which I can query for. Is this a reasonable method? Or is there a clearer way (I mean, I create an activity just for query usages)? Thanks, Menny On Feb 14, 12:44 am, Mark Murphy mmur...@commonsware.com wrote: Menny wrote: I don't know what the other ContentProviders URI are. They can be anything, I want to release my keyboard service, and then release layouts as I need. This means that, somehow, the keyboard service needs to know which layout packages are installed on the device, and what are the URI of their content-providers. Another alternative is to still use Context.createPackageContext(), but primarily as a bootstrap. The APK would publish its content URI in a pre-determined resource (e.g., R.string.any_soft_keyboard_provider_uri), which you would then use. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android Development Wiki:http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en