Hi,

I have a instrumentation class test method which invokes is suppose to
start an activity and wait for its result.

My activity has only one intent "android.intent.action.MAIN".

What is wrong with the below code ?
My activity oncreate returns setResult(0) , once it is finished its
work


this is my instrumenatation class test method

public void test1()
{
Context cnxt  = getInstrumentation().getContext();
Intent funcIntent = new Intent("android.intent.action.MAIN");

//activity name and package name
funcIntent.setClassName("th.fuc","th.fuc.TestActivity");
funcIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);


//this works, for result call startActivityForResult on activity
//cnxt.startActivity(funcIntent);


Activity act = new Activity();
//wait for result
act.startActivityForResult(funcIntent, 10);     //this is crashing
}


public boolean onActivityResult(int requestCode, int resultCode,
Intent data) {
//do check return value
return false;
}



This error log:
W/System.err(  794): java.lang.NullPointerException^M
W/System.err(  794):    at android.app.Activity.startActivityForResult
(Activity.java:2656)^M
W/System.err(  794):    at tr.pack.InstrTest.test1(InstrTest.java:74)
^M
W/System.err(  794):    at java.lang.reflect.Method.invokeNative
(Native Method)^M
W/System.err(  794):    at java.lang.reflect.Method.invoke(Method.java:
521)^M
W/System.err(  794):    at
android.test.InstrumentationTestCase.runMethod
(InstrumentationTestCase.java:191)^M
W/System.err(  794):    at android.test.InstrumentationTestCase.runTest
(InstrumentationTestCase.java:181)^M
W/System.err(  794):    at junit.framework.TestCase.runBare
(TestCase.java:127)^M
W/System.err(  794):    at junit.framework.TestResult$1.protect
(TestResult.java:106)^M
W/System.err(  794):    at junit.framework.TestResult.runProtected
(TestResult.java:124)^M
W/System.err(  794):    at junit.framework.TestResult.run
(TestResult.java:109)^M
W/System.err(  794):    at junit.framework.TestCase.run(TestCase.java:
118)^M
W/System.err(  794):    at android.test.AndroidTestRunner.runTest
(AndroidTestRunner.java:164)^M
W/System.err(  794):    at android.test.AndroidTestRunner.runTest
(AndroidTestRunner.java:151)^M
W/System.err(  794):    at
android.test.InstrumentationTestRunner.onStart
(InstrumentationTestRunner.java:418)^M
W/System.err(  794):    at android.app.Instrumentation
$InstrumentationThread.run(Instrumentation.java:1520)^M
E/My_LOG (  794): java.lang.NullPointerException^M


Can't I launch a android.intent.action.MAIN intent from
startActivityForResult?

Regards,
dev
--~--~---------~--~----~------------~-------~--~----~
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