I was studying some sample examples for Android and one of them got me really curious:
the NoteList (or Notepad) example application - here
My question is: Is there any way to make a NoteList shortcut, that always starts the application with its 'Editor' activity, for example. [of course if the creator of that 'third-party' application intended to make it possible by describing the entry points of its application in a proper way in the manifest file. I do not intent to create malware.]
in other words:
Can a third-party application (like the one I wish to make :) ) to get to internal application intents {i.e. action, activity, data} or this is handled by Android and no one else?
What gave the idea that this is possible was the following case:
I opened NoteList, created a few note, and when I was editing the title of one of the notes - I pressed HOME, when I clicked on the icon of NoteList I got the exact same state of the application - editing the title of the note.
thanks!
One has nothing to do with the other. That means that reopen an activity which was paused or killed with a data restoring logic just restores the last state. This is what happened in your example.
Now what you mean I guess is if there is a way to tell Android that you application can do a certain thing thus it should be shown as an option in the action chooser. Yes that is possible through intent filters.
The Intent reference page might also be very informative for you.
Related
I've created an app that has been in the android marketplace for a few months now. I'm trying to create a complimentary app that will be used inside the first app. I need the second app to be optional, and not necessary for the first app to work properly. I'm hoping to call the main activity from the second app within a Tab Host tab on the first app.
My questions are: how do I run an activity from a secondary app with a different package? Is it possible to have the activity be in a tab host?
I'd be happy to post code, but my code seems to be nowhere close to what I'm trying to get. I don't think I can adjust the build path of the primary app, because the secondary app can't be required. Also, Since the app has been in the marketplace for a while, I can't use SharedUserIds.
Thanks for all help.
TJ
It is not possible to do it to run any arbitrary activity in your app.
I have done this before, with activity group, which has been already deprecated. And there are also limitations to use this approach:
Your app has the same UID with the target package.
Your app has system UID
If you met either condition list above, you can start the child activity and get its window root view, and add into your layout.
It seems like from the various tutorials ive seen people would jump from one activity to another by calling intents from the activity they are working on.
ex:intent(this, anotheractivity.class)
sometimes I see people just using the class they are going to as the parameter
ex: intent (android.content.blahblahblah)
whats the difference in functionality?
is the second made for default classes?
help is much appreciated
There are two "types" of Intents. One is called and explicit Intent in which you tell Android the specific class you are trying to reach (i.e. MyClass.class). The other case uses Android's filtering system to give you the best "match" for the Class you are targeting. When you call new Intent(String action) you are specifying an action to match with some IntentFilter. If your app shares the IntentFilter with some other app, then a dialog will pop up so the user can select which app he/she wants to use.
I've been searching and I couldn't find a topic that could clarify me 100%.
My question is: How can I launch an android's app preferences activity (from Contacts, Messages, ...) on my own app?
I give an example:
Imagine I'm developing an app which allows the user to quickly access to Message's Settings. I don't need to send or receive any information, I only need to open the activity, create a shortcut for it.
Someone knows if this can be done and even opening specific locations of the apps?
You don't need to know any specific locations or specific apps for these actions, simply look into Intent.ACTION_PICK.
Picking a Contact: get contact info from android contact picker
Picking a picture: How to pick an image from gallery (SD Card) for my app?
The best answer in this thread has the solution:
android: how do i open another app from my app?
Also check:
http://android-developers.blogspot.com/2009/01/can-i-use-this-intent.html
To open settings, you can try:
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS, 0));
There is no difference in writing in code an Explicit Intent which will go to a specific activity of your app and using the same format to go to a specific activity some other app. A few things to be aware of: (1) The receiving activity may be expecting particular data and fail otherwise. (2) The standard apps you are considering like Contacts, Messages while you can find the source for them in the Android Open Source Project (AOSP) may be changed by the manufacturers so that the activity names and necessary extra data could be different.
In order to maintain as much compatibility between all of the different Android manufacturers, you should stick to the standard implicit intent with the appropriate action/data.
I've built an app called xLancer (https://market.android.com/details?id=kz.jay.xlancer.activity) that retrieves job listings from Elance. Now i want to implement a feature that would remind me to bid on a project at a later time. Instead of reinventing the wheel i want to launch any external TODO/Task manager app. But now i am stuck, i don't know which URI or action should be specified, so far i've only used intents to call my internal activities by specifying class name explicitly.
So the question is: how can i know which URI/action should be specified?
Look here, I didn't see any Todo/Task intents there though....
If I want to create custom address book (which overrides my phone's default address book), and if I want it to be used by all applications, what should be my intent-filter? Does Android allow me to do such a thing considering the fact that such a third-party app could potentially be malicious?!
And, if I want to have yet another address book application, I suppose the second app also has same intent-filter, isn't it? How does the framework decide which app to pick if I click on Contacts button when making a call? In other words, how does the framework resolve intents in case,there is a conflict between multiple intent-filters?
You can replace any application on Android platform, even Home. Android documentation explains everything there is to know about Intents and Intent Filters and there is a section called Intent Resolution that answers your question. Intent Resolution section for Intent class has some additional information.
As far as I can tell Android doesn't try to resolve a conflict. It ask the user which application to run and gives them the choice to mark this Activity as the default for this Intent. They give an example about mail app here.
While Mr. Smiljanić is basically correct, there is no Contacts application in Android for you to replace. There is Dialtacts, which is the application supporting the contacts, call log, and dialer. That application cannot be replaced, mostly because the dialer cannot be replaced.
So, while you may be able to override some intent filters and get control on some contacts-related requests, you will be unable to get the contacts portion of Dialtacts overridden, which will confuse users.