1

我有两个相关的活动:MainShowResult。第二个是从Main. 这很好用,但是一旦Main在后台,活动就不会打开。Logcat 没有显示任何异常。

显现:

<activity
        android:name="com.....ShowResultActivity"
        android:launchMode="singleTop"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
    </activity>

    <activity
        android:name="com......MainActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.Holo.Wallpaper.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

线程类中的处理程序/从线程执行:

iOpen = new Intent(context, ShowResultActivity.class); // is written in the constructor
Bundle b = new Bundle(); // global

b.putInt("type", 1);
b.putString("url", value);
iOpen.putExtras(b);
context.startActivity(iOpen);

显示结果:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    onNewIntent(getIntent());
}

@Override 
public void  onNewIntent(Intent i) {
    Bundle b = i.getExtras();
    int value = b.getInt("type");
    String url = b.getString("url");

    Log.e("opened :)", value+" "+url);

    if(value == 0) {
        showPictureAsync(url);
    } else if (value == 1) {
        showVideoAsync(url);
    }

}
4

1 回答 1

0

将此添加到您的代码中

iOpen.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(iOpen);
于 2013-03-23T19:24:08.637 回答