0

我正在開發一個應用程序,可以屏幕固定aka企業擁有單一使用aka鎖任務模式。COSU:無法找到活動後引腳,然後重新啓動

如果我腳,然後:

  • 我關閉它(殺死它),然後我再次啓動它
  • 或之後在Android Studio中的一些代碼修改,然後執行運行
  • 重啓後銷,以及取消固定

我得到以下錯誤:

[homtom-ht3_pro-ABCDEF]: E/AndroidRuntime: FATAL EXCEPTION: main 
                Process: com.xx.yyy, PID: 7928 
                java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xx.yyy/com.xx.yyy.activities.LauncherActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.xx.yyy/com.xx.yy.activities.StartActivity}; have you declared this activity in your AndroidManifest.xml? 
                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534) 
                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614) 
                 at android.app.ActivityThread.access$800(ActivityThread.java:178) 
                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
                 at android.os.Handler.dispatchMessage(Handler.java:111) 
                 at android.os.Looper.loop(Looper.java:194) 
                 at android.app.ActivityThread.main(ActivityThread.java:5643) 
                 at java.lang.reflect.Method.invoke(Native Method) 
                 at java.lang.reflect.Method.invoke(Method.java:372) 
                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
                 Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.xx.yyy/com.xx.yyy.activities.StartActivity}; have you declared this activity in your AndroidManifest.xml? 
                 at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1788) 
                 at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512) 
                 at android.app.Activity.startActivityForResult(Activity.java:3809) 
                 at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50) 
                 at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79) 
                 at android.app.Activity.startActivityForResult(Activity.java:3760) 
                 at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859) 
                 at android.app.Activity.startActivity(Activity.java:4090) 
                 at android.app.Activity.startActivity(Activity.java:4058) 
                 at com.xx.yyy.activities.LauncherActivity.onCreate(LauncherActivity.java:16) 
                 at android.app.Activity.performCreate(Activity.java:6099) 
                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) 
                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481) 
                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)  
                 at android.app.ActivityThread.access$800(ActivityThread.java:178)  
                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)  
                 at android.os.Handler.dispatchMessage(Handler.java:111)  
                 at android.os.Looper.loop(Looper.java:194)  
                 at android.app.ActivityThread.main(ActivityThread.java:5643)  
                 at java.lang.reflect.Method.invoke(Native Method)  
                 at java.lang.reflect.Method.invoke(Method.java:372)  
                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)  
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)  

這是我的清單:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.xx.yyy"> 



    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <receiver 
      android:name=".receivers.DeviceAdminReceiver" 
      android:description="@string/app_name" 
      android:label="@string/app_name" 
      android:permission="android.permission.BIND_DEVICE_ADMIN"> 
      <meta-data 
       android:name="android.app.device_admin" 
       android:resource="@xml/device_admin_receiver" /> 

      <intent-filter> 
       <action android:name="android.intent.action.DEVICE_ADMIN_ENABLED" /> 
       <action android:name="android.intent.action.PROFILE_PROVISIONING_COMPLETE" /> 
       <action android:name="android.intent.action.BOOT_COMPLETED" /> 
      </intent-filter> 
     </receiver> 

     <activity android:name=".activities.LauncherActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

     <activity android:name=".activities.StartActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.HOME" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 

    </application> 

</manifest> 

如果我從來沒有腳,我可以重新啓動應用程序/升級&跑了很多次,我想。

好的是,甚至無法卸載應用程序,因爲它已被配置爲設備所有者,因此,除非出廠重置,否則無法卸載它。

我不明白我的活動在應用程序重新啓動後如何消失。可以與intent category or action相關嗎?

如果有其他人遇到這種行爲可以告訴我,我會提交一個問題到bug報告網站。

謝謝。

編輯18/3

我想,也許這是在某一點發生,因爲,我殺home category activity,在我的情況是有問題的失蹤StartActivity,即使我重新啓動它沒有重新啓動應用程序。

回答

0

發現在我的COSU禁用牽制實施的解決方案,我在做:

PackageManager mPackageManager = getApplicationContext().getPackageManager();; 
mPackageManager.setComponentEnabledSetting(
     new ComponentName(getApplicationContext(), StartActivity.class), 
     PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 
     PackageManager.DONT_KILL_APP); 

來禁用設備啓動的牽制,但其實這禁用指定的組件。

正確的實現將是:

PackageManager mPackageManager = getApplicationContext().getPackageManager();; 
mPackageManager.setComponentEnabledSetting(
     new ComponentName(getApplicationContext(), StartActivity.class), 
     PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 
     PackageManager.DONT_KILL_APP);