2016-11-07 2 views
0

내 응용 프로그램의 최신 버전을 다운로드 한 후 installationn보기를 시작하려고하지만 응용 프로그램이 새 활동을 시작할 때 항상 중단됩니다.응용 프로그램 설치보기 시작


이 내 방송 수신기

**private BroadcastReceiver downloadReceiver = new BroadcastReceiver() { 
    @Override 
    public void onReceive(Context context, Intent intent) { 
     //check if the broadcast message is for our Enqueued download 
     long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1); 
     if (downloadReference == referenceId) { 
      Log.v(LOG_TAG, "Downloading of the new app version complete"); 
      //start the installation of the latest version 
      Intent installIntent = new Intent(Intent.ACTION_VIEW); 
      installIntent.setDataAndType(downloadManager.getUriForDownloadedFile(downloadReference), "application/vnd.android.package-archive"); 
      installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      startActivity(installIntent); 
     } 
    } 
};** 

Process: com.astech.android.webxbettingsystem, PID: 17476 
       java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.DOWNLOAD_COMPLETE flg=0x10 pkg=com.astech.android.webxbettingsystem (has extras) } in com.astech[email protected]1282c32 
        at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:932) 
        at android.os.Handler.handleCallback(Handler.java:815) 
        at android.os.Handler.dispatchMessage(Handler.java:104) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:5737) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
       Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://downloads/my_downloads/572 typ=application/vnd.android.package-archive flg=0x10000000 } 
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1809) 
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523) 
        at android.app.Activity.startActivityForResult(Activity.java:3968) 
        at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48) 
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75) 
        at android.app.Activity.startActivityForResult(Activity.java:3920) 
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856) 
        at android.app.Activity.startActivity(Activity.java:4259) 
        at android.app.Activity.startActivity(Activity.java:4227) 
        at com.astech.android.webxbettingsystem.ui.activity.CheckAppUpdateActivity$1.onReceive(CheckAppUpdateActivity.java:55) 
        at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:922) 
        at android.os.Handler.handleCallback(Handler.java:815)  
        at android.os.Handler.dispatchMessage(Handler.java:104)  
        at android.os.Looper.loop(Looper.java:207)  
        at android.app.ActivityThread.main(ActivityThread.java:5737)  
        at java.lang.reflect.Method.invoke(Native Method)  
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)  
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)  

누군가가 나에게 도움이 내 로그 캣 제발

+0

확인 제발 당신의 코드를 설명해주세요 – hrskrs

+0

예 내가이 ** ChecAppUpdateActivity **에'CheckAppUpdateActivity'을 추가 한 경우

@Override public void onReceive(Context context, Intent intent) { long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1); if (downloadReference == referenceId) { DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(downloadReference); Cursor cursor = (DownloadManager) getSystemService(Context.DOWNLOAD_MANAGER).query(query); if (cursor.moveToFirst() && cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_SUCCESSFUL) { String filePath cursor.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME)); Log.v(LOG_TAG, "Downloading of the new app version complete"); //start the installation of the latest version Intent installIntent = new Intent(Intent.ACTION_VIEW); installIntent.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(installIntent); } cursor.close(); } } 

답변

1

당신은 당신의 Uri에 전달하는 방식을 변화 시도 할 수 있습니다. 다운로드 한 파일의 로컬 경로를 보유하는 COLUMN_LOCAL_FILENAME 열을 사용하여 0123으로 만듭니다.이 밖으로 나옵니다.

당신의 코드는 같이 보일 것입니다 :

당신이 내 *의 AndroidManifest.xml **
+0

작동하지만 ** COLUMN_LOCAL_FILENAME **은 (는) 더 이상 사용되지 않습니다. –

+0

Google에서 사용하도록 제안 된 내용을 시험해 볼 수 있습니다. https://developer.android.com/reference /android/app/DownloadManager.html#COLUMN_LOCAL_FILENAME, 개인적으로 사용하지 않았습니다. –

0

텐트를 처리 할 수 ​​없음 활동. 당신의 activity

<intent-filter> 
      <action android:name="android.intent.action.VIEW"/> 
      <category android:name="android.intent.category.DEFAULT"/> 
      <category android:name="android.intent.category.BROWSABLE"/> 

      <data 
       android:host="your-link.com" 
       android:scheme="http"/> 
     </intent-filter> 
+0

에'AndroidManifest.xml' –

+0

ACTION_VIEW를 사용할 때 활동에 대한 인 텐트 필터를 설정해야합니다. –

0

intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK)에 대한 manifest에서 intent-filter를 사용; . 활동에서 시작되지 않은 경우 시작이 새로운 활동, intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK "이 필요할 때

두 텐트 필터를 가지고, 당신은 단지 하나의 필요 당신이를 통해 브로드 캐스트 리시버를 등록합니다. registerReceiver(),는 해당 API 호출에 두 번째 매개 변수 인로 IntentFilter를 사용 - 또한 매니페스트에의 요소를 넣지 마십시오

+0

** registerReceiver() **를 사용합니다 ** –

+0

여기에 등록합니다. '''' IntentFilter filter = new IntentFilter (DownloadManager.ACTION_DOWNLOAD_COMPLETE); registerReceiver (downloadReceiver, filter); –

+0

그런 다음 registerReceiver – Raju

관련 문제