Issue
I am trying to setup an Intent helper class called "GetIntents". My problem is, how would I call my GetIntents helper class from an activity?
Here is my GetIntents helper class:
public class GetIntents extends Intent {
public static Intent i;
public static String username = i.getExtras().getString("uid");
public static String password = i.getExtras().getString("pwd");
public static String firstName = i.getExtras().getString("firstName");
public static String lastName = i.getExtras().getString("lastName");
public static String lastLatitudeUpdate = i.getExtras().getString("lastLatitudeUpdate");
public static int checkedin = i.getExtras().getInt("checkedin");
public static int Minute = i.getExtras().getInt("Minute");
public static int Hour = i.getExtras().getInt("Hour");
}
Now im not sure how I would be able to call it from my activity. So far I have tried:
GetIntents intent = new GetIntents();
intent.getIntent();
I've also tried a couple other ways, but no luck. Any suggestions on what I could try?
My logs:
06-21 11:26:18.249: D/AndroidRuntime(8978): Shutting down VM
06-21 11:26:18.249: W/dalvikvm(8978): threadid=1: thread exiting with uncaught exception (group=0x40015578)
06-21 11:26:18.253: E/AndroidRuntime(8978): FATAL EXCEPTION: main
06-21 11:26:18.253: E/AndroidRuntime(8978): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.jetdelivery.mobile/com.jetdelivery.mobile.screen1}: java.lang.NullPointerException
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.os.Looper.loop(Looper.java:130)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.app.ActivityThread.main(ActivityThread.java:3687)
06-21 11:26:18.253: E/AndroidRuntime(8978): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 11:26:18.253: E/AndroidRuntime(8978): at java.lang.reflect.Method.invoke(Method.java:507)
06-21 11:26:18.253: E/AndroidRuntime(8978): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
06-21 11:26:18.253: E/AndroidRuntime(8978): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
06-21 11:26:18.253: E/AndroidRuntime(8978): at dalvik.system.NativeStart.main(Native Method)
06-21 11:26:18.253: E/AndroidRuntime(8978): Caused by: java.lang.NullPointerException
06-21 11:26:18.253: E/AndroidRuntime(8978): at com.jetdelivery.mobile.GetIntentHelper.getDataModel(GetIntentHelper.java:9)
06-21 11:26:18.253: E/AndroidRuntime(8978): at com.jetdelivery.mobile.screen1.<init>(screen1.java:66)
06-21 11:26:18.253: E/AndroidRuntime(8978): at java.lang.Class.newInstanceImpl(Native Method)
06-21 11:26:18.253: E/AndroidRuntime(8978): at java.lang.Class.newInstance(Class.java:1409)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-21 11:26:18.253: E/AndroidRuntime(8978): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
06-21 11:26:18.253: E/AndroidRuntime(8978): ... 11 more
Solution
Thank you everyone for your help. I have decided to go another route instead of using a helper class.
Intent i = getIntent();
username = i.getExtras().getString("uid");
password = i.getExtras().getString("pwd");
firstName = i.getExtras().getString("firstName");
lastName = i.getExtras().getString("lastName");
lastLatitudeUpdate = i.getExtras().getString("lastLatitudeUpdate");
checkedin = i.getExtras().getInt("checkedin");
Minute = i.getExtras().getInt("Minute");
Hour = i.getExtras().getInt("Hour");
Answered By - John Nguyen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.