Nitin Thakor
Nitin Thakor

Reputation: 535

How to open my Image in one specif application from the list of different application?

I want to open the image in the specific application by default from the list of different gallery application. I am able to get the list of available application. But I want to choose one specific Application by default without displaying the list of application. it is possible in Phone setting but I want to do it programmatically.

  Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");

            PackageManager pm = getPackageManager();
            List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, 0);
            List<String> intentList = new ArrayList<>();

            String packageName = null;

            for (int i=0;i<resInfo.size();i++){
                ResolveInfo ri = resInfo.get(i);
                packageName = ri.activityInfo.packageName;
                intentList.add(packageName);
            }

            startActivity(intent);

Thanks for the help in Advance.....

Upvotes: 3

Views: 32

Answers (1)

codeFreak
codeFreak

Reputation: 353

You need to pass in the app's package name in setPackage() when creating your intent.

intent.setPackage("com.example.gallery"); startActivity(Intent.createChooser(intent, "View Image"));

Upvotes: 1

Related Questions