0

버튼을 클릭하면 PDF 파일을 열 수있는 응용 프로그램이 있습니다. 그것은 안드로이드의 모든 버전에 functionnal했지만 그것은 안드로이드 7.1.1에 충돌 왜 모르겠어 :이 내가Android 7.1.1의 ActivityNotFoundException

ActivityNotFoundException when starting

No Activity found to handle Intent splash screen

살펴 보았다 관련 질문이/

내 기능은 MainActivity에서 파일을 엽니 다 :

private void readPDF({ 
    File f = new File(getFilesDir(), "toto.pdf"); 

    if (!f.exists()) { 
     AssetManager assets=getResources().getAssets(); 

     try { 
      copy(assets.open("toto.pdf"), f); 
     } 
     catch (IOException e) { 
      Log.e("FileProvider", "Exception copying from assets", e); 
     } 
    } 

    Intent intent = new Intent(Intent.ACTION_VIEW); 
    Uri uri = getUriForFile(this, getApplicationContext().getPackageName() + ".fileprovider", f); 
    intent.setDataAndType(uri, "application/pdf"); 
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
    revokeUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); 
    startActivity(intent); 
} 

private void copy(InputStream in, File dst) throws IOException { 
    FileOutputStream out=new FileOutputStream(dst); 
    byte[] buf=new byte[1024]; 
    int len; 

    while ((len=in.read(buf)) > 0) { 
     out.write(buf, 0, len); 
    } 

    in.close(); 
    out.close(); 
} 

내 매니페스트 :

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.fr"> 
<application 
    android:allowBackup="true" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

    <provider 
     android:name="android.support.v4.content.FileProvider" 
     android:authorities="com.example.fr.fileprovider" 
     android:exported="false" 
     android:grantUriPermissions="true"> 
     <meta-data 
      android:name="android.support.FILE_PROVIDER_PATHS" 
      android:resource="@xml/provider_paths"/> 
    </provider> 

    <activity 
     android:name="com.example.fr.MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

마지막 오류 코드 :

04-26 08 : 15 : 16.991 21748-21748/com.example.fr E/AndroidRuntime : 치명적인 예외 : 주요 프로세스 : com.example.fr, PID : 21748 android.content.ActivityNotFoundException : Intent {act = android.intent.action.VIEW dat = content : //com.example.fr.fileprovider/assets/toto를 처리 할 활동이 없습니다. pdf typ = application/pdf flg = 0x1} android.app의 android.app.Activity.startActivityForResult (Activity.java:4225) 에서 android.app.Instrumentation.execStartActivity (Instrumentation.java:1523) 에서 .Instrumentation.checkStartActivityResult (Instrumentation.java:1809) 에서 android.support.v4 android.app.Activity.startActivityForResult (Activity.java:4183)에서 android.support.v4.app.FragmentActivity.startActivityForResult (FragmentActivity.java:75) 에서 .app.BaseFragmentActivityJB.startActivityForResult (BaseFragmentActivityJB.java:48) (액티브 .java : 4522) android.app.Activity.startActivity (Activity.java:4490) at com.example.fr.MainActivity.readPDF (MainActivity.java:58) at com.example.fr.MainActivity.access $ 000 (MainActivity.java : 21) at com.example.fr.MainActivity $ 1.onClick (MainActivity.java:34) at android.view.View.performClick (View.java:5637) android.view.View $ PerformClick.run (View.java : 22429) android.os.Handler.handleCallback (Handler.java:751) at android.os.Handler.dispatchMessage (Handler.java:95) at android.os.Looper.loop (루퍼. java : 154) android.app.ActivityThread.main (ActivityThread.java:6119) at java.lang.reflect.Method.invoke (네이티브 메소드) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java : 886) at com.android.internal.os.ZygoteInit.main (ZygoteInit.자바 : 776)

감사의 도움

+0

어떤 응용 프로그램에서 PDF 파일을 처리 할 것으로 예상합니까? 해당 응용 프로그램이 설치되어 있지 않을 수 있습니다. –

답변

1

문제에 대한 당신이 텐트를 처리 할 수있는 응용 프로그램이 있는지 확인하지 않고, 의도를 엽니 시스템을 강제하는 것입니다. 아마 당신은 PDF 파일을 읽을 수있는 응용 프로그램이없는 장치에서 PDF를 열려고합니다. 이 코드를 사용해보십시오 :

PackageManager packageManager = getActivity().getPackageManager(); 
if (intent.resolveActivity(packageManager) != null) { 
    startActivity(intent); 
} else { 
    Log.d(TAG, "No Intent available to handle action"); 
} 
0

그것은

없음 안드로이드

의 모든 버전에 functionnal했다, 그것은 아니었다. 테스트 한 안드로이드 기기에서 작동하는 기기 였고, 그 기기에 content 구성표를 지원하는 PDF 뷰어가 설치되었습니다. Android 자체에는 PDF 뷰어가 없으며 모든 장치에 PDF 뷰어가 있고 다중 사용자 장치의 모든 사용자가 PDF 뷰어에 액세스 할 필요는 없습니다.

하지만 안드로이드 7.1.1에이 충돌하고 내가 아는하지 않는 이유

당신이 content 방식을 지원하는 PDF 뷰어가없는에서 테스트하는 장치.