Sorry... I should have checked my logCat ... in fact onCreate has already been called at the point where the NullPointerException is thrown.
On Nov 10, 5:42 pm, hackbod <[EMAIL PROTECTED]> wrote: > Probably you are calling this before Activity.onCreate(), which is > where the mInstrumentation field is set. > > Note that calling into an activity from a Service like this is pretty > sketchy -- you will need to be very very careful about activity > lifecycle and updating the service as the activity changes. > > On Nov 10, 2:22 pm,dreamerBoy<[EMAIL PROTECTED]> wrote: > > > Thanks for your reply - ha ha, wouldn't that be nice if it were that > > simple. Nope, I checked the return from the Uri.parse - not null. > > > I got a hold of the Android source code. It is crashing here in > > Activity.java: > > > public void startActivityForResult(Intent intent, int > > requestCode) { > > if (mParent == null) { > > Instrumentation.ActivityResult ar = > > ----->>> mInstrumentation.execStartActivity( > > this, mMainThread.getApplicationThread(), mToken, > > th .... > > > intent, requestCode); > > > Apparently, mInstrumentation is null. > > mInstrumentation is set in a routine called attach in Activity.java. > > > I am trying to launch the Activity inside a Service - I don't see > > anything that says that's illegal. However, clearly, I'm not giving > > Android something that it wants. > > > Still scratching my head on this one for the time being... > > > On Nov 7, 6:10 pm, Chris <[EMAIL PROTECTED]> wrote: > > > > You don't check if Uri.parse returns null, do you? > > > > On Fri, Nov 7, 2008 at 3:53 PM,dreamerBoy<[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > I'm attempting to initiate an outgoing call from inside a Service. > > > > > In onStart(), I create an ACTION_CALL Intent, then attempt to start an > > > > Activity > > > > > myIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + > > > > phoneNumber)); > > > > > initiateCall.startActivityForResult(myIntent, > > > > CALL_SETUP_ACTIVITY_ID); > > > > > However, when I run the code I get a NullPointerException. Clearly, > > > > the intent and activity are non-null, so I'm wondering what Android is > > > > lacking here. > > > > > 11-07 13:24:19.801: INFO/PhoneTestService(1250): onCreate called > > > > 11-07 13:24:19.801: INFO/PhoneTestService(1250): onStart called > > > > 11-07 13:24:19.801: INFO/PhoneTestService(1250): doIt called > > > > 11-07 13:24:19.811: DEBUG/PhoneTestService(1250): creating > > > > initiateCall activity > > > > 11-07 13:24:19.811: DEBUG/PhoneTestService(1250): initiateCall is NOT > > > > NULL!!!!! > > > > 11-07 13:24:19.820: INFO/PhoneTestService(1250): phone state is: > > > > CALL_STATE_IDLE > > > > 11-07 13:24:21.601: INFO/PhoneTestService(1250): starting to listen > > > > Fri Nov 07 13:24:19 PST 2008 > > > > 11-07 13:24:21.622: INFO/PhoneTestService(1250): starting call intent. > > > > 11-07 13:24:21.622: DEBUG/PhoneTestService(1250): myIntent is NOT > > > > NULL!!!!! > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): ERROR: > > > > java.lang.NullPointerException > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): > > > > java.lang.NullPointerException > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > android.app.Activity.startActivityForResult(Activity.java:2528) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > test.phone.PhoneTestService.doIt(PhoneTestService.java:254) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > test.phone.PhoneTestService.onStart(PhoneTestService.java:145) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2429) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > android.app.ActivityThread.access$3100(ActivityThread.java:112) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1640) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > android.os.Handler.dispatchMessage(Handler.java:88) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > android.os.Looper.loop(Looper.java:123) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > android.app.ActivityThread.main(ActivityThread.java:3742) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > java.lang.reflect.Method.invokeNative(Native Method) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > java.lang.reflect.Method.invoke(Method.java:515) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > com.android.internal.os.ZygoteInit > > > > $MethodAndArgsCaller.run(ZygoteInit.java:739) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) > > > > 11-07 13:24:21.632: ERROR/PhoneTestService(1250): at > > > > dalvik.system.NativeStart.main(Native Method) > > > > > Don't know where to go from here... > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > <manifest xmlns:android="http://schemas.android.com/apk/res/android" > > > > package="test.phone" > > > > android:versionCode="1" > > > > android:versionName="1.0.0"> > > > > <application> > > > > <activity android:name=".PhoneTest" > > > > android:label="@string/app_name"> > > > > <intent-filter> > > > > <action android:name="android.intent.action.MAIN" /> > > > > <category > > > > android:name="android.intent.category.LAUNCHER" /> > > > > </intent-filter> > > > > </activity> > > > > <activity android:name=".PhoneTestActivity"> > > > > <intent-filter> > > > > <action > > > > android:name="android.intent.action.ACTION_CALL" /> > > > > <category > > > > android:name="android.intent.category.DEFAULT" /> > > > > </intent-filter> > > > > </activity> > > > > <service android:name=".PhoneTestService"></service> > > > > </application> > > > > > <uses-permission android:name="android.permission.CALL_PHONE"></uses- > > > > permission> > > > > <uses-permission > > > > android:name="android.permission.SET_ACTIVITY_WATCHER"></uses- > > > > permission> > > > > <uses-permission android:name="android.permission.STATUS_BAR"></uses- > > > > permission> > > > > <uses-permission android:name="android.permission.SET_DEBUG_APP"></ > > > > uses-permission> > > > > <uses-permission android:name="android.permission.CALL_PRIVILEGED"></ > > > > uses-permission> > > > > <uses-permission > > > > android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses- > > > > permission> > > > > <uses-permission android:name="android.permission.READ_PHONE_STATE"></ > > > > uses-permission> > > > > > </manifest> > > > > > Any ideas appreciated. > > > > > Thanks, > > > > > Paul > > > > -- > > > Chris A. > > > Forthelose.net > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---