title: Android App Force Close when i click some intent
body: <p>I try the tutorial from Youtube to make Text Recognition from Camera, but somehow the app force close</p>
  <h1>Logcat</h1>
  <pre><code>2021-01-14 17:10:49.411 26731-26731/? E/le.masunprojec: Unknown bits set in runtime_flags: 0x28000 &lt;br/&gt;
  2021-01-14 17:10:49.497 26731-26760/com.example.masunproject E/Perf: Fail to get file list com.example.masunproject &lt;br/&gt;
  2021-01-14 17:10:49.498 26731-26760/com.example.masunproject E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array &lt;br/&gt;
  2021-01-14 17:10:49.498 26731-26760/com.example.masunproject E/Perf: Fail to get file list com.example.masunproject &lt;br/&gt;
  2021-01-14 17:10:49.498 26731-26760/com.example.masunproject E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array &lt;br/&gt;
  2021-01-14 17:10:49.498 26731-26760/com.example.masunproject E/Perf: Fail to get file list oat &lt;br/&gt;
  2021-01-14 17:10:49.498 26731-26760/com.example.masunproject E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array &lt;br/&gt;
  2021-01-14 17:10:57.315 26731-26731/com.example.masunproject E/AndroidRuntime: FATAL EXCEPTION: main &lt;br/&gt;
      Process: com.example.masunproject, PID: 26731 &lt;br/&gt;
      java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=android/com.android.internal.app.ResolverActivity clip={text/uri-list U:content://media/external/images/media/476840} (has extras) } from ProcessRecord{2689c68 26731:com.example.masunproject/u0a421} (pid=26731, uid=10421) with revoked permission android.permission.CAMERA &lt;br/&gt;
          at android.os.Parcel.createException(Parcel.java:2087)&lt;br/&gt;
          at android.os.Parcel.readException(Parcel.java:2055)&lt;br/&gt;
          at android.os.Parcel.readException(Parcel.java:2003)&lt;br/&gt;
          at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:3872)&lt;br/&gt;
          at android.app.Instrumentation.execStartActivity(Instrumentation.java:1714)&lt;br/&gt;
          at android.app.Activity.startActivityForResult(Activity.java:5319)&lt;br/&gt;
          at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)&lt;br/&gt;
          at android.app.Activity.startActivityForResult(Activity.java:5263)&lt;br/&gt;
          at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)&lt;br/&gt;
          at com.example.masunproject.MainActivity.add(MainActivity.java:74)&lt;br/&gt;
          at com.example.masunproject.MainActivity.access$000(MainActivity.java:25)&lt;br/&gt;
          at com.example.masunproject.MainActivity$3.onClick(MainActivity.java:61)&lt;br/&gt;
          at android.view.View.performClick(View.java:7256)&lt;br/&gt;
          at android.view.View.performClickInternal(View.java:7218)&lt;br/&gt;
          at android.view.View.access$3800(View.java:824)&lt;br/&gt;
          at android.view.View$PerformClick.run(View.java:27719)&lt;br/&gt;
          at android.os.Handler.handleCallback(Handler.java:883)&lt;br/&gt;
          at android.os.Handler.dispatchMessage(Handler.java:100)&lt;br/&gt;
          at android.os.Looper.loop(Looper.java:228)&lt;br/&gt;
          at android.app.ActivityThread.main(ActivityThread.java:7782)&lt;br/&gt;
          at java.lang.reflect.Method.invoke(Native Method)&lt;br/&gt;
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)&lt;br/&gt;
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)&lt;br/&gt;
       Caused by: android.os.RemoteException: Remote stack trace: &lt;br/&gt;
          at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1155)&lt;br/&gt;
          at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:979)&lt;br/&gt;
          at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:636)&lt;br/&gt;
          at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1803)&lt;br/&gt;
          at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:567)&lt;br/&gt;
  </code></pre>
  <h1>MainActivity</h1>
  <pre><code>public class MainActivity extends AppCompatActivity {&lt;br/&gt;
      ImageView imageView,speak,capture;&lt;br/&gt;
      EditText editText;&lt;br/&gt;
      String s;&lt;br/&gt;
      TextToSpeech textToSpeech;&lt;br/&gt;
      Uri uri;&lt;br/&gt;
      private static final int IMAGE_PICK_CAMERA_CODE=1001;&lt;br/&gt;
      @Override&lt;br/&gt;
      protected void onCreate(Bundle savedInstanceState) {&lt;br/&gt;
          super.onCreate(savedInstanceState);&lt;br/&gt;
          setContentView(R.layout.activity_main);&lt;br/&gt;
          editText = findViewById(R.id.editView);&lt;br/&gt;
  
  
  
          textToSpeech=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int i) {
  
              }
          });
  
          speak=findViewById(R.id.speak);
          capture=findViewById(R.id.capture);
          imageView=findViewById(R.id.imageView);
  
          speak.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  textToSpeech.speak(s,TextToSpeech.QUEUE_FLUSH,null);
  
              }
          });
  
          capture.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  add();
              }
          });
  
      }
  
      private void add() {
          ContentValues values=new ContentValues();
          values.put(MediaStore.Images.Media.TITLE, &quot;Picture&quot;);
          values.put(MediaStore.Images.Media.DESCRIPTION, &quot;Camera to speak&quot;);
          uri=getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
          Intent c=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          c.putExtra(MediaStore.EXTRA_OUTPUT,uri);
          startActivityForResult(c, IMAGE_PICK_CAMERA_CODE);
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
          capture.setVisibility(View.GONE);
          speak.setVisibility(View.VISIBLE);
  
          if(requestCode==IMAGE_PICK_CAMERA_CODE){
              CropImage.activity(uri)
                      .setGuidelines(CropImageView.Guidelines.ON)
                      .start(this);
          }
          CropImage.ActivityResult result= CropImage.getActivityResult(data);
          Uri uri=result.getUri();
          imageView.setImageURI(uri);
  
          BitmapDrawable bitmapDrawable=(BitmapDrawable) imageView.getDrawable();
          Bitmap bitmap=bitmapDrawable.getBitmap();
  
          TextRecognizer recognizer=new TextRecognizer.Builder(getApplicationContext()).build();
          Frame frame=new Frame.Builder().setBitmap(bitmap).build();
          SparseArray&lt;TextBlock&gt; item=recognizer.detect(frame);
          StringBuilder stringBuilder=new StringBuilder();
  
          for(int i=0;i&lt;item.size();i++){
              TextBlock myitem=item.valueAt(i);
              stringBuilder.append(myitem.getValue());
              stringBuilder.append(&quot;\n&quot;);
          }
  
          editText.setText(stringBuilder.toString());
          s=stringBuilder.toString();
  
          super.onActivityResult(requestCode, resultCode, data);
      }
  }
  </code></pre>
  <h1>Manifest</h1>
  <pre><code>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.masunproject&quot;&gt;
  
      &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;/&gt;
      &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;
      &lt;uses-permission android:name=&quot;android.permission.CAMERA&quot;/&gt;
  
      &lt;application
          android:allowBackup=&quot;true&quot;
          android:icon=&quot;@mipmap/ic_launcher&quot;
          android:label=&quot;@string/app_name&quot;
          android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
          android:supportsRtl=&quot;true&quot;
          android:theme=&quot;@style/AppTheme&quot;&gt;
          &lt;activity android:name=&quot;.MainActivity&quot;&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=&quot;com.theartofdev.edmodo.cropper.CropImageActivity&quot;
              android:theme=&quot;@style/AppTheme&quot;/&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  
  
  </code></pre>