0

I have some code working good in api < 24 but in api 24 it's not working and crashes the app. code:

File root = new File(path);
Uri uri = Uri.fromFile(root);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/jpeg");
startActivity(intent);

So how to use intent in android >= 7 (api >= 24)?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Hossin Asaadi
  • 367
  • 6
  • 13

1 Answers1

0

Try this to switch from an Activity to another using intent:

Intent int = new Intent(MainActivity.this, ActActivity.class);
startActivity(int);
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
chaimae
  • 16
  • 2
  • [Is it ok to write "hope that helps" or why is my answer being edited (duplicate)](https://meta.stackoverflow.com/q/258187/6045800) – Tomerikoo Feb 12 '23 at 13:34