简体   繁体   中英

Screen Locked causing Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml?

I have been getting this error in my application for quite a sometime now at few client devices. I have posted a related question Here but found not useful answer.

After weeks of research and testing, i reproduce this error at development machine.

On login activity, after user insert required credentials and click Login button , I am running a AsyncTask to validate the credentials over the server. In between i am showing ProgressDialog to the user. In case if am locked the device during doInBackground execution using device hardware lock key or it dims by own and lock, PostExecute method throws exception. Following is code snippet of PostExecute . Normally without Locking the device it works well

if(EveryThing Goes Well) 
{                     
    progressDialogUtil.Dismiss();
    Intent selectBikeActivity = new Intent(getApplicationContext(), SelectBike.class);
    startActivity(selectBikeActivity); // Here Raised Exception
    finish();
}
......

StackTrace is

 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.yego.motodriver/com.yego.motodriver.SelectBike}; have you declared this activity in your AndroidManifest.xml?
                                                 at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
                                                 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:50)
                                                 at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
                                                 at android.app.Activity.startActivityForResult(Activity.java:3920)
                                                 at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
                                                 at android.app.Activity.startActivity(Activity.java:4259)
                                                 at android.app.Activity.startActivity(Activity.java:4227)
                                                 at com.yego.motodriver.Login.HandleLoginResponse(Login.java:502)
                                                 at com.yego.motodriver.Login.access$300(Login.java:61)
                                                 at com.yego.motodriver.Login$4.onGRPCTaskCompleted(Login.java:233)
                                                 at com.yego.util.GrpcTask.onPostExecute(GrpcTask.java:297)
                                                 at com.yego.util.GrpcTask.onPostExecute(GrpcTask.java:38)
                                                 at android.os.AsyncTask.finish(AsyncTask.java:651)
                                                 at android.os.AsyncTask.-wrap1(AsyncTask.java)
                                                 at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
                                                 at android.os.Handler.dispatchMessage(Handler.java:111)
                                                 at android.os.Looper.loop(Looper.java:207)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5742)
                                                 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)

How to avoid this Exception ?

You have not declare your activity in AndroidManifest.xml like :

<activity
        android:name=".SelectBike"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM