jsu*_*din 17 android android-intent android-activity
出于某种原因,每当我(尝试)启动我的应用程序时,手机决定启动系统设置而不是我的"主要活动".是的,我指的是"Android系统设置",而不是我的应用程序.
这只发生在我的手机上,我想这可能与我的应用刚刚打开系统设置的事实有关,当我决定用Eclipse的新版本重新启动时.
可以从Eclipse中启动应用程序,但是当我从应用程序导航回来时它返回到系统设置而不是主屏幕,就好像首先启动设置活动然后启动我的活动一样.如果我然后从手机启动应用程序,我得到的只是系统设置.
该应用程序正在侦听特定URL子字符串的VIEW操作,当我使用匹配的URL启动应用程序时,我得到的结果与从Eclipse启动应用程序时相同,应用程序启动,但是当我返回时,我返回设置.
我已经尝试使用谷歌搜索这个问题,而我所能找到的是关于Android 应用程序被杀死时的Android 保存状态,但没有任何关于如何重置此状态的信息.我试过卸载应用程序,查杀系统设置,重新启动手机,重新安装,清除应用程序数据..没有运气..
对于它的价值,这里是清单中我主要活动的定义,
<activity android:name=".HomeActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:clearTaskOnLaunch="true" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:pathPrefix="/isak-web-mobile/smart/" android:scheme="http" android:host="*"></data>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
这是从我尝试启动我的应用程序时的logcat行,没有任何关于任何设置的地方.
I/ActivityManager( 1301): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=se.opencare.isak/.HomeActivity }
Run Code Online (Sandbox Code Playgroud)
当我从Eclipse启动时,我也得到了这一行(正如人们所期望的那样),
I/ActivityManager( 1301): Start proc se.opencare.isak for activity se.opencare.isak/.HomeActivity: pid=23068 uid=10163 gids={3003, 1007, 1015}
Run Code Online (Sandbox Code Playgroud)
如果重要的话,手机是HTC Desire Z,运行2.2.1.
目前,这是我的HomeActivity,
public class HomeActivity extends Activity {
public static final String TAG = "HomeActivity";
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + ", " + resultCode + ", " + data + ")");
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate(" + savedInstanceState + ")");
super.onCreate(savedInstanceState);
}
@Override
protected void onDestroy() {
Log.d(TAG, "onDestroy()");
super.onDestroy();
}
@Override
protected void onPause() {
Log.d(TAG, "onPause()");
super.onPause();
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
Log.d(TAG, "onPostCreate(" + savedInstanceState + ")");
super.onPostCreate(savedInstanceState);
}
@Override
protected void onPostResume() {
Log.d(TAG, "onPostResume()");
super.onPostResume();
}
@Override
protected void onRestart() {
Log.d(TAG, "onRestart()");
super.onRestart();
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
Log.d(TAG, "onRestoreInstanceState(" + savedInstanceState + ")");
super.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onResume() {
Log.d(TAG, "onResume()");
super.onResume();
}
@Override
protected void onStart() {
Log.d(TAG, "onStart()");
super.onStart();
}
@Override
protected void onStop() {
Log.d(TAG, "onStop()");
super.onStop();
}
@Override
protected void onUserLeaveHint() {
Log.d(TAG, "onUserLeaveHint()");
super.onUserLeaveHint();
}
}
Run Code Online (Sandbox Code Playgroud)
没有(上述内容)写入日志.
在阅读Blundell的回复后,我尝试更改launchMode/clearTaskOnLaunch设置,并得到以下结果:
我已经在我的手机上对此进行了测试,但这似乎在这里可以正常工作...如果您尝试创建一个新项目,然后将代码复制到其中怎么办?它对我有用,也许对你也有用......
我怀疑这与您更改 Eclipse 版本有关,这可能会使用与您之前使用的版本不同的设置,因此使您的初始设置毫无用处......
| 归档时间: |
|
| 查看次数: |
1993 次 |
| 最近记录: |