New Approach ...

I have a "Hello, World"-type program.  Basically all I do is say
"Hello, World", install a useless button with a button-handler (to
forestall ANR a little), and then I attempt to make a call with the
ACTION_CALL Intent.

I am no longer attempting to start the ACTION_CALL Activity from a
Service!

I invoke the following statements inside the onResume() method of my
main "Hello, World" activity:

Uri parsedPhoneNumber = Uri.parse("tel:1234567");
Intent myIntent = new Intent(Intent.ACTION_CALL, parsedPhoneNumber);
Activity myPhoneTestActivity = new Activity();

myPhoneTestActivity.startActivityForResult(myIntent,
CALL_SETUP_ACTIVITY_ID);  <== Crashes here, NullPointer

Thus, the ACTION_CALL is now being launched as a sub-Activity.
The behavior of this code inside an Activity is the same as it is
inside a Service - it crashes at the same place with a
NullPointerException (null mInstrumentation).

Hackbod pointed out that the previous crash (mInstruction = null,
according to Activity.java) was due to the fact that onCreate was not
being called for the Activity.  So I FAKED a call to onCreate(), to
whit:

Uri parsedPhoneNumber = Uri.parse("tel:1234567");
Intent myIntent = new Intent(Intent.ACTION_CALL, parsedPhoneNumber);
Activity myPhoneTestActivity = new Activity();

==> myPhoneTestActivity.onCreate();

myPhoneTestActivity.startActivityForResult(myIntent,
CALL_SETUP_ACTIVITY_ID); <== Still crashes here but different

Of course, you're probably thinking that's not going to work and ..
you'd be right!

11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
Uncaught Exception Handler - thread: Thread[main,5,main] exception:
android.app.ActivityThread.performResumeActivity(ActivityThread.java:
2504)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:
2519)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2159)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
android.app.ActivityThread.access$1800(ActivityThread.java:112)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
android.os.Handler.dispatchMessage(Handler.java:88)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
android.os.Looper.loop(Looper.java:123)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
android.app.ActivityThread.main(ActivityThread.java:3742)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
java.lang.reflect.Method.invokeNative(Native Method)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
java.lang.reflect.Method.invoke(Method.java:515)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:739)
11-12 10:56:33.802: ERROR/test.phoneTest.PhoneTestActivity(1295):
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
11-12 11:19:19.828: ERROR/test.phoneTest.PhoneTestActivity(309):
dalvik.system.NativeStart.main(Native Method)

Error appears to be more deeply entangled in Android's inner
workings...
I was curious about how the ACTION_CALL was handled so I started doing
searches in the Android source code.

> /bin/find . -name '*.java' -print | xargs grep ACTION_CALL

Apparently, there is no code that handles this ... (checked the core
classes as well as anything having to do with phones or telephony..)

I'm asking myself now:  Is ACTION_CALL implemented at all??  Is it
implemented but just not in the Emulator??

I'm attempting to launch this new Activity with the ACTION_CALL Intent
and Android does not ~appear~ anyway, to know what to do with it.  If
that theory is true, then no wonder the Activity is crashing...

The other possibility of course, is that I am misunderstanding how to
set this up correctly.

<?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.GET_TASKS"></uses-
permission>
<uses-permission
android:name="android.permission.SYSTEM_ALERT_WINDOW"></uses-
permission>
<!--  Apparently this no longer exists -
<uses-permission
android:name="android.permission.RUN_INSTRUMENTATION"></uses-
permission>
-->
<!--  Android is refusing to grant me these permissions.
<uses-permission
android:name="android.permission.SET_ACTIVITY_WATCHER"></uses-
permission>
<uses-permission android:name="android.permission.CALL_PRIVILEGED"></
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.PROCESS_OUTGOING_CALLS"></uses-
permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></
uses-permission>
<!-- This Instrumentation stuff doesn't appear to do anything ...
Android ignores ...-->
<instrumentation android:targetPackage="test.phone"
android:name=".PhoneTestInstrumentation"></instrumentation>

</manifest>


On Nov 10, 4:33 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
> dreamerBoywrote:
> > However, same error.
>
> I'm somewhat skeptical that launching an activity, particularly via
> startActivityForResult(), will work from a service. I know it's in the
> API, but think about what that means: some background process can cause
> a full-fledged activity to spawn in front of the user, in the middle of
> the user doing something else? That really violates the spirit of the UI
> Android seems to be aiming for.
>
> Are you sure you want a service spawning this activity, instead of some
> other activity doing it? Or maybe use Notifications or something?
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
>
> Android Training on the Ranch! -- Mar 16-20, 
> 2009http://www.bignerdranch.com/schedule.shtml
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to