Android : destroy activity before intent to another activity -
I have two activities in my Android application:
1. Login Activation: By using a user member Login / Password & Email or as guest
2. Main Activity: Showing the user's current location on the map
Scenario: < Br> 1. User login guest. 2. Go to main activity as guest (no NPE is not here)
User Ta said that some action was required to login 4. intent log entry 5. The user is required to destroy the main activity before giving instructions to login. 6. User input username and password on login activity 7. If the user exists and passwords really go to MainActivity 8. NPE (or tap pointer exception) happened here.
So, in my case, I need it to destroy the main activity (point number 5) before directing the user to log-in activity. I have tried to:
Final AlertDialog Builder Builder = New AlertDialog Builder (reference); Last string message = getResources (). GetString (R.string.NCI); Builder.setMessage (Html.fromHtml () "To do your work, we need you to log into our server") .setTitle ("login required") .setPositiveButton ("OK", New OnClickListener () { Public Zero onClick (DialogInterface D, Int id) {Intent I = New Intent (main activity., Login activity.class); i.setFlags (intestine.FLAG_ACTIVITY_CLEAR_TOP); initialization (i); end ();}}); Builder.create () Show ().; Log Cat 07-25 16: 04: 27.287: E / Android Random (1923): Death Cases: Main 07-25 16 : 04: 27.287: E / AndroidRuntime (19,823): java.lang.RuntimeException: Java: Activity to start ComponentInfo {com.yai.properti.tujuh.tujuh.tujuh / com.yai.properti.tujuh.tujuh.tujuh Unable to .MainActivity}. Lang.NullPointerException 07-25 16: 04: 27.287: E / AndroidRuntime (19,823): android.app.ActivityThread.performLaunchActivity (ActivityThread.java2097) at 07-25 16: 04: 27.287: E / AndroidRuntime (19,823): 04: 27.287: android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2122) 07-25 16E / AndroidRuntime (19,823): android.app.ActivityThread.access $ 600 (ActivityThread.java:140) 07-25 16 : 04: 27.287: E / Android Random (1923): Android App ActiveTrade $ H Hondal Message (ActivityTrad.Java 228) 07-25 16: 04: 27.287: E / Android Time (1923): Android. Handhear Dispatchmessage (Handler. Java: 99) 07-25 16: 04: 27.287: E / Android Random (1923): Android.OS Looper Loop (Luor.Java Projections 37) 07 -25 16: 04: 27.287: E / Android Random (1 9 23): Android. App ActiveTatrad.mine (ActivityTrad.Java 4895) 07-25 16: 04: 27.287: E / Android Time (1923): at java.lang Reflect.Method.invokeNative (Basic Method) 07-25 16: 04: 27.287: E / Android Random (1923): at java.lang.reflect.Method.invoke (Method.java: 1111) 07-25 16:04 : 27.287: E / Android Random (1923): com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:994) 07-25 16: 04: 27.287: E / Android Time (19823): com .internal.os.zygoteInit.main (ZygoteInit.java:761) 07-25 16: 04: 27.287: E / Android Time (1923): Delvic on android. System NetStart.Mine (Original Method) 07-25 16:04: 27.287: E / AndroidRuntime (19,823): java.lang.NullPointerException 07-25 16: 04: 27.287: E / AndroidRuntime (19,823) due to: com.yai (MainActivity.java:817) 07-25 16: 04: 27.287: E / Android Random (1923): Android. App Activate.Perform Create (activity.Java 51, 63) 07-25 16: 04: 27.287: E / AndroidManman (1983): On one ndroid.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1094) 07-25 16 : 04: 27.287: E / AndroidRuntime (19,823): android.app.ActivityThread.performLaunchActivity (ActivityThread.java2061) at 07-25 16: 04: 27.287: E / Android Random (1923): ... 11 more I have tried Destory () Finnish () by changing the call method, but NPE (Null Pointer exception) still happened. For the first time as the main activity intent, there is no interest in NPE.
What do I need for the first time the main activity begins .
Whenever you have to call end () to To end some activity within an anonymous internal class , just as you did in the code above, just pass the name of the entire activity (which you want to delete), such as main activity. Finnish () .. (where the main activity is that you want to delete)
Comments
Post a Comment