For some reason whenever I (try to) start my app the phone decides to launch system settings instead of my "main activity". And yes, I am referring to the "Android system settings", and not something from my app.
这只出现在我的电话上,我相信,这很可能与我的用人刚刚打开了系统环境这一事实有关,当时我决定用新版本从Eclipse重新发射。
It is possible to start the app from within Eclipse, but when I navigate back from the app it returns to the system settings rather than the home screen, as if the settings activity was started first and then my activity. If I then start the app from the phone all I get is system settings yet again.
当时,我听到了世界展望组织对特定卢爱阵列的反应,当我开始使用一种对称的URL,我取得的结果与我从Eclipse开始,而是回到我的环境一样。
I have tried googling for this problem, and all I could find was something about Android saving state when an app gets killed, but without any information on how to reset this state. I have tried uninstalling the app, killing system settings, rebooting the phone, reinstalling, clearing application data.. no luck..
对我的主要活动从清单中界定,这符合我的价值。
<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>
这里,从我试图开始我,就没有任何情况。
I/ActivityManager( 1301): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=se.opencare.isak/.HomeActivity }
当我从Eclipse发射时,我也照此行(如预期的),
I/ActivityManager( 1301): Start proc se.opencare.isak for activity se.opencare.isak/.HomeActivity: pid=23068 uid=10163 gids={3003, 1007, 1015}
如果电话是HTCZ, 运行2.2.1。
Currently, this is my 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();
}
}
(以上)任何内容均不写给该记录。
在阅读了Blundell的回复之后,我尝试改变发射Mode/clearTaskOnLaunch的环境,结果如下:
- Situation A - I remove launchMode and clearTaskOnLaunch: same problem as before
- Situation B - I remove clearTaskOnLaunch and keeps launchMode="singleInstance": another problem
- Open app - My HomeActivity is showing
- Click on a button to open another activity within my app - it opens as it should
- Click on the system back-button - it returns me to system settings
- Click on the system back-button again - I am returned to my HomeActivity
- Another click on the back-button brings me back to the Android home screen
- Situation C - I remove only launchMode and keeps clearTaskOnLaunch: same problem as before
- Sitatuion D - I remove clearTaskOnLaunch and set launchMode="singleInstance": same as situation B