English 中文(简体)
1. 声像发射系统,而不是我的照片
原标题:Android launches system settings instead of my app

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
问题回答

You are not calling setContentView() from the HomeActivity (as per the code added by you). And when it is not present, different device behave differently, like on emulator you will see "Application not installed on your phone". Try setting content view.

I ve tested this on my phone, but this seems to work correctly here... What if you try to create a new project, and then just copy the code into it? It worked for me, maybe it will work for you to...

I suspect it has something to do with your change of version of Eclipse, which might use some different setting from the version you used before, therefore rendering your initial set-up as useless...

我的2名议员

你可以研究申请的发射活动。

基本上,我认为可能发生的情况是,你正在像环境一样,在座,因此,本组织将把环境推向屏幕上,然后把你的活动排在这一顶端。

You could try adding:

android:launchMode="singleInstance"

页: 1 这将为您的申请开启一个新的栏目。 阁下

This may fix the issue but there may be another cause and this may cause adverse effects depending on how your app works. Have a look at the documentation for further info:Android:LaunchMode

阅读你的发言,为什么不仅删除<条码>android: 发射Mode=“singleTop”,而且让它在发生违约时发射?

您也正在将这一条与以下各项相配:android:clearTaskOnLaunch,因为本组织有环境活动和你的活动,与“的任务相同。 是否有这样的理由?

请注意,我不是安乐施会家,但我有安乐施会的电话,认为这个问题非常有趣。

我在此总结一下我迄今为止对这个问题的理解,我看着以下可能是这一问题的根源:

  • You use clearTaskOnLaunch, which wipes out all intents/activities/tasks/whatever_buzzword_is_used_for_this when your application starts.
  • Android then seems to remember permanently the last state of the application in some (what I now will call) global internal state database (GISD for brevity) which cannot be wiped that easily (at least not with uninstalling the application, rebooting, clearing intents, etc.).
  • Android tries to reopen the application with it s last state. If there is no current activity then this info is taken from the GISD, hence in your case it is "system settings".
  • There is no way (or it is unknown how) to wipe the state held in the GISD. (Your question is how to do that.)

如果确实如此,这显然是一个电话问题,是安的一家大棒,因为你可能把砖加瓦。 你们都必须做到以下几点:

  • Somehow provoke a similar thing like clearTaskOnLaunch - which should be possible - for the application you want to brick.
  • Trick the application to launch to some other application like "System settings" - many applications do this to enable WiFi or similar, but I think some clever people (read: not me) will find a way to do this for virtually any application
  • Now kill the application in this state.

Android will remember that state then in the GISD and if you try to launch the application from Home screen this will fail in future. Nice.

However even in the absence of a fix hopefully it is possible to bring back the application the same way:

  • Start your application with an Activity such that it launches. As you write, this works for you.
  • Apply what clearTaskOnLaunch does. (I really have no idea how, but you as Android developer probably know.)
  • Let your application launch a third application such that this third application becomes the global state.
  • Kill your application.

也许时机和顺序很重要,因此,或许在你的申请被害之后,或许你必须离开第三份申请,或许你必须在适当的时候抽打你的电话,或许你必须用一些听力的亚行来阻止您的电话做正确的事,或许你需要另一轮行动,或者说,不管怎么说,甚至会发现如何挑出你的错误——但是,由于你发现我们知道有这样的事情。

如果你能够从家庭屏幕上提出第三份申请,而不是你认为这可以证实,你确实能够解决这一问题。 如果这样做不可行,那么就不可能防止安乐斯援引系统环境而不是你的用意,那么安康肯定会遇到一个大问题,因为有人可能会找到一种办法,在那里所有这些贵重电话中永久 b(ab)使用这种灯。

If the previous step works, however, the last step now is to let this third application launch back into the main screen of your application:

  • Start your application.
  • This will launch the third application.
  • Apply what clearTaskOnLaunch does.
  • Let the third application launch your application s main screen (or whatever you want)
  • Kill the third application (and perhaps your application).

现在,全球活动状态应重新适用——如果所有申请都不会受到损害的话。

Note that I am not sure this really can be done, as I am not able to test it myself. And having said that all, I agree that we certainly need be a better way to repair this issue!

但令人感兴趣的是,如果你们的表态是第三位,而第三位的表态是你们的。 这是否会导致无休止的 lo?

同样令人感兴趣的是,如果你去掉第三点,情况会发生。 这是否使自动发射变成了该申请,或使你无助?

我必须说,作为铁丝网塔(仅是),你发现的冰冰层。 因此,如果存在固定装置,我非常感兴趣,因为工厂重新铺设不能被视为解决办法。 阅读: 这不仅是一个开发商的问题,也影响到安的用户。

PS: Please forgive me my bad English, the length of this post, not using the right Buzzwords and posting on an issue which I am not an expert of so that my answer is a little bit OT. However I do this with HTH.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...