I have installed 2 Facebook app on my android device (com.facebook.katana, com.facebook.katanb).
Now, I want to open a post id on com.facebook.katanb package.
I tried as below:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://post/2377836809193490"));
intent.setPackage("com.facebook.katanb");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
However, It's not worked.
Is there anyone who could help me?
Related
I am having a problem with android email intent.....i need to open email app so that the user can provide feedback for my app.It doesn't open when i use this..throws an ActivityNotFoundException .....i am using my phone ,not an emulator and my phone has email and gmail apps in it.
Help me solve??
Here is my code:
Intent intent= new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.setType("text/plain");
String[] mail={"someone#gmail.com"};
intent.putExtra(Intent.EXTRA_SUBJECT,"");
intent.putExtra(Intent.EXTRA_TEXT,"");
intent.putExtra(Intent.EXTRA_EMAIL,mail);
startActivity(intent);
Any and all comments are appreciated :)
For your case, what ActivityNotFoundException most likely means that in your phone you don't have any default email app email application installed on your device like Gmail, so when you launch the Intent you receive this error.
You can try to handle that exception like this:
try {
startActivity(Intent.createChooser(i, "Send mail"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Activity.this, "no email app",Toast.LENGTH_SHORT).show();
}
From the android docs, An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a picture") in an Intent object. This type of intent is called an implicit intent because it does not specify the app component to start, but instead specifies an action and provides some data with which to perform the action.
When you call startActivity() or startActivityForResult() and pass it an implicit intent, the system resolves the intent to an app that can handle the intent and starts its corresponding Activity. If there's more than one app that can handle the intent, the system presents the user with a dialog to pick which app to use.`
So, in your case, the system couldn't find an app to resolve the intent to as #Tamir mentioned.
For more information , look into this Stack Overflow post: Send Email Intent
it works for me :
String[] recipients;
Intent intent = new Intent(Intent.ACTION_SEND);
recipients = new String[]{"someone#gmail.com"};
intent.putExtra(Intent.EXTRA_EMAIL, recipients);
intent.setType("text/html");
intent.setPackage("com.google.android.gm");
try {
activity.startActivity(Intent.createChooser(intent, "Send"));
}
catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Activity.this, "no email app",Toast.LENGTH_SHORT).show();
}
My sharing intent code does work with all other apps but not reddit when i try to share it with reddit i get a toast saying "Something went wrong." I tried several codes but none worked for me. Here's my current code, Please help me solving this problem.
private void share(File file){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+file.getAbsolutePath()));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(intent,"Share with..."));
}
public void shareMessage(){
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
getContext().startActivity(Intent.createChooser(intent, "Share"));
}
When I use "text/plain", Facebook comes up as an option but the text does not load up when selecting it. But the text does load for Twitter,email, SMS.
Has anyone else encountered this problem?
As mentioned in the comments , Facebook has disabled the share intent a few years back Android and Facebook share intent , it doesn't handle EXTRA_SUBJECT or EXTRA_TEXT fields,
Use the Facebook api , Instructions found here --> https://developers.facebook.com/docs/android/share#share_options
is it possible to take the user to Settings -> Location using intent, so he would be able to enable the app go get the device location?
This is the screen I want to go to:
Try this:
Intent intent= new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
sorry for my english, and need a little help
im bulding an app, and this app need to import a ovpn file to the openvpn connect app.
im run this command from adb and work fine
adb shell am start -n net.openvpn.openvpn/.OpenVPNAttachmentReceiver -a android.intent.action.VIEW -d "/MyPcHardDis/profile.ovpn" -t "application/x-openvpn-profile"
but if im building an intent to launch the same command
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setComponent(new ComponentName("net.openvpn.openvpn","net.openvpn.openvpn.OpenVPNAttachmentReceiver"));
intent.setData(Uri.parse("/storage/emulated/0/Download/asdf.ovpn"));
intent.setType("application/x-openvpn-profile");
startActivity(intent);
after launch, the openvpn app open but doesnt import the profile.
the intent is wrong?
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setComponent(new ComponentName("net.openvpn.openvpn","net.openvpn.openvpn.OpenVPNAttachmentReceiver"));
intent.setDataAndType(Uri.parse(file_path), "application/x-openvpn-profile");
startActivity(intent);
Using the Ionic Framework with the startapp plugin you can do this:
navigator.startApp.start([
["net.openvpn.openvpn","net.openvpn.openvpn.OpenVPNAttachmentReceiver"],
["cdvfile://localhost/persistent/Download/asdf.ovpn"]
], function(message) {
/* success */
},
function(error) {
/* error */
});