Advertisement
MrBIMC

Untitled

Aug 7th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1.            
  2.             //как надо:
  3.             Intent photoPickerIntent = new Intent();
  4.             photoPickerIntent.setType("*/*");
  5.             getActivity().startActivityForResult(photoPickerIntent, PICK_IMAGE);
  6.             //---------
  7.  
  8.  
  9.             //что было у них:
  10.             Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  11.             //pickIntent.setType("image/*");
  12.             pickIntent.setType("*/*");
  13.  
  14.             Intent intent = new Intent(Intent.ACTION_PICK);
  15.             intent.setPackage("com.omichsoft.gallery");
  16.             intent.setType("*/*");
  17.  
  18.             PackageManager pm = getActivity().getPackageManager();
  19.             List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
  20.  
  21.             if (apps == null || apps.size() == 0) {
  22.                 Intent marketIntent = new Intent(Intent.ACTION_VIEW);
  23.                 marketIntent.setData(Uri.parse("market://details?id=com.omichsoft.gallery"));
  24.                 marketIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  25.                 try {
  26.                     startActivity(marketIntent);
  27.                 } catch (android.content.ActivityNotFoundException e) {
  28.                     e.printStackTrace();
  29.                     Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.omichsoft.gallery"));
  30.                     browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  31.                     startActivity(browserIntent);
  32.                 }
  33.             } else {
  34.                 getActivity().startActivityForResult(intent, PICK_IMAGE);
  35.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement