活动从其启动另一个应用程序时销毁

时间:2014-04-29 12:51:58

标签: android android-intent android-fragments android-activity

我已经实现了多个片段的活动,从我生成pdf文件的一个片段到查看我正在打开pdf阅读器(Adope pdf阅读器),但是当我从pdf阅读器返回时我的应用程序的活动重启..如何停止那件事..

这是我开始使用pdf阅读器的代码

  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setDataAndType(Uri.fromFile(file),"application/pdf");
  intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
  context.startActivity(intent);  

这里是我的应用程序的行为生命堆栈

活动的暂停名为

片段onsave叫

活动的onsave叫

活动的onstop称为

活动的onDestroy名为

活动的开始名为

活动的onRestoreInstanceStat名为

活动的onPause名为

活动的onsave叫

活动的onstop称为

活动的onDestroy名为

活动的开始名为

活动的onRestoreInstanceState名为

这里是清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.project"
 android:versionCode="1"
 android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19"
    />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<supports-screens android:smallScreens="false"
              android:normalScreens="false"
              android:largeScreens="false"
              android:xlargeScreens="true"
                android:anyDensity="true"
              android:requiresSmallestWidthDp="600"
           />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:name=".ApplicationClass"

     >
    <activity
        android:name="com.example.project.LoginScreen"
        android:label="@string/app_name" android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.project.General"
        android:label="@string/app_name" android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.general" />

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

1 个答案:

答案 0 :(得分:1)

由于活动的方向改变,出现了这个问题。 我刚刚在manifest.xml中的活动中添加了以下行,这解决了我的问题......

android:configChanges="keyboardHidden|orientation|screenSize"