Reputation: 620
I tried to open page my Instagram page for a user who wants to follow. I tried some code to do that work:
private void followInsta() {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://www.instagram.com/motivationalquotes.app"));
try {
intent.setPackage("com.instagram.android");
startActivityForResult(Intent.createChooser(intent, mContext.getResources().getString(R.string.app_name)), 1000);
} catch (Exception e) {
try {
Log.e("FollowInsta1>>>", Log.getStackTraceString(e));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivityForResult(Intent.createChooser(intent, mContext.getResources().getString(R.string.app_name)), 1000);
} catch (Exception ex) {
Log.e("FollowInsta2>>>", Log.getStackTraceString(ex));
}
}
}
I called this from a click
event but its always open dialog with a message My app name and 'No apps can perform this action'
This is only happening with the Samsung Galaxy J8 device. But it normally works on other devices. If anyone knows what to try for these types of devices then please tell me. I also tried this to solve my problem but it didn't work!
Upvotes: 0
Views: 244
Reputation: 871
Try this snippet:
Uri uri = Uri.parse("http://instagram.com/_u/motivationalquotes.app");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
likeIng.setPackage("com.instagram.android");
try {
startActivity(likeIng);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/motivationalquotes.app")));
}
This should open the app if installed or call the browser.
Upvotes: 1