10-21 01:05:37.121: I/TestRunner(1224): ----- begin exception ----- 10-21 01:05:37.131: I/TestRunner(1224): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? 10-21 01:05:37.131: I/TestRunner(1224): at android.app.ContextImpl.startActivity(ContextImpl.java:847) 10-21 01:05:37.131: I/TestRunner(1224): at android.content.ContextWrapper.startActivity(ContextWrapper.java:276) 10-21 01:05:37.131: I/TestRunner(1224): at com.hello.jifenshenqi.common.Utils.startApp(Utils.java:55) 10-21 01:05:37.131: I/TestRunner(1224): at com.hello.jifenshenqi.test.DemoTest.test_1_taobao(DemoTest.java:50) 10-21 01:05:37.131: I/TestRunner(1224): at java.lang.reflect.Method.invokeNative(Native Method) 10-21 01:05:37.131: I/TestRunner(1224): at java.lang.reflect.Method.invoke(Method.java:511) 10-21 01:05:37.131: I/TestRunner(1224): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214) 10-21 01:05:37.131: I/TestRunner(1224): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199) 10-21 01:05:37.131: I/TestRunner(1224): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186) 10-21 01:05:37.131: I/TestRunner(1224): at junit.framework.TestCase.runBare(TestCase.java:127) 10-21 01:05:37.131: I/TestRunner(1224): at junit.framework.TestResult$1.protect(TestResult.java:106) 10-21 01:05:37.131: I/TestRunner(1224): at junit.framework.TestResult.runProtected(TestResult.java:124) 10-21 01:05:37.131: I/TestRunner(1224): at junit.framework.TestResult.run(TestResult.java:109) 10-21 01:05:37.131: I/TestRunner(1224): at junit.framework.TestCase.run(TestCase.java:118) 10-21 01:05:37.131: I/TestRunner(1224): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 10-21 01:05:37.131: I/TestRunner(1224): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 10-21 01:05:37.131: I/TestRunner(1224): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:537) 10-21 01:05:37.131: I/TestRunner(1224): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551) 10-21 01:05:37.131: I/TestRunner(1224): ----- end exception -----
原因分析:
Context中有一个startActivity方法,Activity继承自Context,重载了startActivity方法。如果使用 Activity的startActivity方法,不会有任何限制,而如果使用Context的startActivity方法的话,就需要开启一个新的task,遇到上面那个异常的,都是因为使用了Context的startActivity方法。解决办法是,加一个flag。intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
解决办法:
Intent intent = new Intent(); intent.setClass(mContext, PhotoView.class); Bundle bundle = new Bundle(); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent);
相关推荐
W/System.err: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? W/System.err: at...
Makes the calling kernel thread take on the specified mm context.
The design presented here is based on the input of numerous professionals from the pointing device manufacturing and Windows soft¬ware development industries. In this document, the words "tablet" ...
To run outside the calling processes address space. OLEDB providers can run in-process or out of process. When running out of process, they run under the context of DLLHOST.EXE. Memory Leak To reserve...
Jess__The_Java_Expert_System_Shell:DistributionCategory UC-411 SAND98-8206 (revised)Unlimited... A guide to calling Java functions from Jess, and to extending Jess by writing Java code, is alsoincluded.
In the context of the JavaMail API, your JavaMail-based program will communicate with your company or Internet Service Provider's (ISP's) SMTP server. That SMTP server will relay the message on to ...
An intent lock indicates that SQL Server wants to acquire a shared (S) lock or exclusive (X) lock on some of the resources lower down in the hierarchy. For example, a shared intent lock placed at the ...
Transplant is an easy way of calling Matlab from Python.zip
GAMS LINGO XPRESS CPLEX MATLAB CPLUSPLUS\cplex_ppt\Tutorial_Calling CPLEX Functions from a C Source File.ppt
[] 匹配中括号里的内容[a-z][A-Z][0-9]。 ! 事件。 $ 取环境变量的值。 | 管道。把前一命令的输出作为后一命令的输入,把几个命令连接起来。 |经常跟tee连用,tee 把内容保存到文档并显示出来。 三、通用后...
The definition of an inline function needs to be in a header file, so that the compiler has the definition available for inlining at the call sites. However, implementation code properly belongs in ....
TRNSYS is a complete and extensible software environment for the transient ... interactive calls during the simulation (e.g. Microsoft Excel, Matlab, COMIS, etc.).
Calling C and C++ from IDL复印版,还挺清楚的。
- FIX: In "Windows ClearType" font rendering mode (OS Windows mode) the "garbage" pixels can appear from the right and from the bottom sides of the painted rectangle of the TFlexText object....
I fixed a bug where a dataset could be put out of search mode by the TIB_Grid calling ValidateRows and causing the dataset to open when it wasn't being expected to. I fixed a bug in the handling of a...
“People will come to expect that injured or diseased organs are meant to be repaired from within, in much the same way that we fix an appliance or automobile: by replacing the damaged part with a ...
The Lifecycle of an Android Activity 100xiv Contents Organizing Activity Components with Fragments 105 Managing Activity Transitions with Intents 106 Transitioning between Activities with Intents 106...
… the enterprise of today has changed … wherever you sit in this new corporation … Srinivasan gives us a practical and provocative guide for rethinking our business process … calling us all to ...