I just want to open About Phone using intent to get the Bluetooth MAC address, I know how to open intent but I don't know the required action. Below are some of the common intents but I didn't find the one I need to open about the phone.
Commen Intents
Following is the code to open intent Action
Intent intent = new Intent(Settings.ACTION_....);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
oh it is simple
use ACTION_DEVICE_INFO_SETTINGS to open device info
Intent intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
startActivity(intent);
Related
I am using the code to call an intent in Android
Intent intent = new Intent();
String PACKAGE_NAME="com...."
intent.setPackage(PACKAGE_NAME);
intent.setAction(Intent.ACTION_VOICE_COMMAND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
getApplication().startActivity(intent);
Unfortunately, in some case, I do not know the PACKAGE_NAME. So, another method is using broadcast. How can I use it? Thanks all
You cant call Activity directly if you dont know package and name of that Activity.
Since you dont know package and Activity name you can only ask OS to show all possible variants for your Intent Action. In most cases user click "always open this app for this action" what means that you will directly open another app.
So in your case your code should looks like
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VOICE_COMMAND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
//dont forget to check if user has at least one application for your Intent Action
if (intent.resolveActivity(getPackageManager()) != null) {
context.startActivity(intent);
}
I want to give the user possibility to open Contacts app from my app, so he can edit them, export etc. What I DON'T WANT is a contact picker where the user selects a contact. I need only to somehow open the Contacts app from my app. How Can I do it ? Intent ?
The following snippet will do what you want .
Intent intent = new Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI);
startActivity(intent);
This should work as expected.
Intent intent = new Intent();
intent.setComponent(new ComponentName(
"com.android.contacts"
,"com.android.contacts.DialtactsContactsEntryActivity");
startActivity(intent)
I'm able to launch the Call Log activity using intent
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(android.provider.CallLog.Calls.CONTENT_URI);
startActivity(intent);
But on selecting any Log (incoming, Outgoing or missed ) from Call Log activity it will initiate a call.
But according to my requirement i want to use above intent using action Intent.ACTION_PICK and startActivityForResult(intent).
please share any idea to do the same.
Assuming I know that the Gallery has an album with a certain name X, what intent or broadcast can I make to open Album X with the Gallery app?
There are plenty of examples showing how to select a picture from the Gallery, but I don't see any describing how to accomplish the above.
Thanks.
try this
Intent intent = new Intent();
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Main.this.startActivity(intent);
program will browser all application are support with image file
but user can set default program
If you prepared the Gallery which is called X, yes you can do it.
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.Xapp");
if (launchIntent != null) {
launchIntent.setData("PHOTO ID OR ANYTHING ELSE");
startActivity(launchIntent);
}
After then you can set data in intent. And X app parses intent data and you can open it.
Otherwise, you can't this action. You only call the app, If the application does not provide API support for send data with intent.
I want to launch the stock weather app from my android app via an
intent, but I keep getting a force close runtime error, and LogCat
gives me nothing. The code I am trying to use to achieve this is:
public void startWeatherActivity() {
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(ComponentName.unflattenFromString("org.anddev.android.weatherforecast/
org.anddev.android.weatherforecast.WeatherForecast"));
intent.addCategory("android.intent.category.LAUNCHER");
startActivity(intent);
}
Try to get your intent from getLaunchIntentFromPackage:
android doc
just as a comment, you should use Intent.ACTION_MAIN instead of the explicit string constant.