I have written the following code in java file in eclipse to make launch of snapchat application on my android device through my application. But when i am running it in my android device it shows "no apps can perform this action".
if(view.getId()==R.id.LaunchSnapchat){
intent= new Intent(android.content.Intent.ACTION_VIEW);
intent.setData(Uri.parse("snapchat://details?id=com.snapchat.android&hl=en&rdid=com.snapchat.android"));
chooser=Intent.createChooser(intent,"Launch Snapchat");
startActivity(chooser);
}
what is the solution??
Simple answer, as taken from here
If you don't know the main activity, then the package name can be used to launch the application.
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.snapchat.android");
if (launchIntent != null) {
startActivity(launchIntent);//null pointer check in case package name was not found
}
Try this
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.setPackage("com.snapchat.android");
startActivity(Intent.createChooser(intent, "Open Snapchat"));
Also work this it is because mabe you did not have snapchat installed (emulator)
if(view.getId()==R.id.LaunchSnapchat){
intent= new Intent(android.content.Intent.ACTION_VIEW);
intent.setData(Uri.parse("snapchat://details?id=com.snapchat.android&hl=en&rdid=com.snapchat.android"));
chooser=Intent.createChooser(intent,"Launch Snapchat");
startActivity(chooser);
}
Related
public void sendCustomIntent(View view) {
Intent intent = new Intent();
intent.setAction("com.examole.intentnbroadcast.CUSTOM_INTENT");
intent.putExtra("message", "Custom Intent Test");
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
sendBroadcast(intent);
}
Hi, i'm a begineer in android dev.
I try to use image button to connect this method but i can't totally understand this code.
I click the button of this method but nothing happend, can someone explain it to me, thanks!!
Now, i'm not sure the code of this, what's its functionality?
intent.setAction("com.examole.intentnbroadcast.CUSTOM_INTENT");
I am developing an app, where I want to share the TEXT and IMAGE to other apps installed on my phone.
But when I click the share button Neither it shares TEXT nor IMAGE just empty it directs me to another app I chose for sharing.
below postDescription and postImage are my methods of model class, and I checked that am I getting values are not in a toast it gives there values properly.
Below is the code:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, postDescription);
Uri uri = Uri.parse(postImage);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
context.startActivity(Intent.createChooser(shareIntent, "Share With"));
So the above bunch of code was not working, then I found code through which I can share my post TEXT and IMAGE to WhatsApp only, I tried that but it shows file formate not supported inside WhatsApp.
below is the code for sharing to WhatsApp only:
Uri imgUri = Uri.parse(postImage);
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, postDescription );
whatsappIntent.putExtra(Intent.EXTRA_STREAM, imgUri);
whatsappIntent.setType("image/jpeg");
whatsappIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
context.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(context, "Whatsapp have not been installed.", Toast.LENGTH_SHORT).show();
}
I want to know how to create a share button that works fine for WhatsApp and everything or only WhatsApp will do the work for me.
By removing the package from the intent, Android should display the list of apps that can handle the type of intent.
Uri imgUri = Uri.parse(postImage); //Provide the URI to the downloaded image, not an external URL
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("*/*");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, postDescription );
whatsappIntent.putExtra(Intent.EXTRA_STREAM, imgUri);
if (whatsappIntent.resolveActivity(packageManager) != null) {
startActivity(whatsappIntent)
}
I was wondering how I can create and start an intent using this:
"qsrtech.posprintdriver/.printservice"
I downloaded the POS Printer Driver (ESC) app (which is the app I am trying to access).
I tried this:
String PrintPage = "qsrtech.posprintdriver/.printservice";
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(ComponentName.unflattenFromString(PrintPage));
intent.addCategory(Intent.CATEGORY_LAUNCHER );
startActivity(intent);
However, I get an error saying:
"No activity found to handle this intent"
I was wondering if there is anything I can do to access this intent? The thing is that I'm not sure if I'm accessing an activity or a background service (probably an intent service?) from a different app.
Here is the link that explains more about this intent.
http://www.qsrtechnologies.com/aboutposdriver.html
You can try with this :
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra("Data", "Test printer\n\n");
sendIntent.setComponent(new ComponentName("qsrtech.posprintdriver","qsrtech.posprintdriver.printservice"));
startService(sendIntent);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra("Data", "Test printer\n\n");
sendIntent.setComponent(new ComponentName("qsrtech.posprintdriver","qsrtech.posprintdriver.printservice"));
startService(sendIntent);
Worked like a charm here.
How am i suppose to use this
android.intent.category.APP_MUSIC
to launch the music player?
it doesn't work if i call makeMainSelectorActivity
Intent intent = new Intent();
intent.makeMainSelectorActivity(intent.ACTION_MAIN,
"android.intent.category.APP_MUSIC");
startActivity(intent);
This solution might help someone looking to launch default Music Player:
if(android.os.Build.VERSION.SDK_INT>=15){
Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
Intent.CATEGORY_APP_MUSIC);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//Min SDK 15
startActivity(intent);
}else{
Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");//Min SDK 8
startActivity(intent);
}
Used below code :
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
or
Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");
startActivity(intent);
Ans also prefer url :
Launching the default music player
I need to know how I could make a button that opens the androids web browser and navigates to a specific URL. I'm using eclipse and already know how to make buttons and click listeners.
Thanks for any help.
Just add this code to onClick():
// Launch a browser
Uri uri = Uri.parse("http://www.yahoo.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Intent websiteIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("http://www.android.com");
websiteIntent.setData(uri);
startActivity(websiteIntent);
Try this
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com");
startActivity(intent);