简体   繁体   English

警告:活动尚未开始,其当前任务已被置于最前面

[英]Warning: Activity not started , its current task has been brought to the front

While working though a book on Android game development, I came across the follwing warning in eclipse: ActivityManager: Warning: Activity not started, its current task has been brought to the front 在阅读有关Android游戏开发的书时,我在eclipse中遇到了以下警告: ActivityManager: Warning: Activity not started, its current task has been brought to the front

Basically, I have 3 projects;Mr.Snake,Mr.Snake.Framework and Mr.Snakey . 基本上,我有3个项目; Snake先生,Snake.Framework先生和Snake先生。

In my Mr.Snake file, I have : 在我的Mr.Snake文件中,我有:

/Mr.Snake/src/com/zardapps/framework/Audio.java
/Mr.Snake/src/com/zardapps/framework/FileIO.java
/Mr.Snake/src/com/zardapps/framework/Game.java
/Mr.Snake/src/com/zardapps/framework/Graphics.java
/Mr.Snake/src/com/zardapps/framework/Input.java
/Mr.Snake/src/com/zardapps/framework/Music.java
/Mr.Snake/src/com/zardapps/framework/MySuperAwesomeGame.java
/Mr.Snake/src/com/zardapps/framework/Pixmap.java
/Mr.Snake/src/com/zardapps/framework/Screen.java
/Mr.Snake/src/com/zardapps/framework/Sound.java

In my Mr.Snake.Framework, I have : 在我的Snake先生框架中,我有:

/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidAudio.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidFileIO.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidGame.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidGraphics.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidInput.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidMusic.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidPixmap.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidSound.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/KeyboardHandler.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/MultiTouchHandler.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/Pool.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/SingleTouchHandler.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/TouchHandler.java
/Mr.Snake.Framework/src/com/zardtechnologies/androidgames/framework/impl/AndroidFastRenderV have :iew.java

In my Mr.Snakey, I have : 在我的斯纳基先生中,我有:

/Mr.Snakey/src/com/zardtechnologies/mrsnakey/Assets.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/GameScreen.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/HighscoreScreen.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/LoadingScreen.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/MainMenuScreen.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/MrSnakey.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/Settings.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/Snake.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/SnakePart.java
/Mr.Snakey/src/com/zardtechnologies/mrsnakey/Stain.java

These are the three projects that make up my MrSnakey game. 这是组成我的MrSnakey游戏的三个项目。 Currently, the error I get from the console 目前,我从控制台收到的错误

[2012-04-26 21:56:59 - Mr.Snakey] Android Launch!
[2012-04-26 21:56:59 - Mr.Snakey] adb is running normally.
[2012-04-26 21:56:59 - Mr.Snakey] Performing com.zardtechnologies.mrsnakey.MrSnakey activity launch
[2012-04-26 21:56:59 - Mr.Snakey] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Test.Phone'
[2012-04-26 21:57:02 - Mr.Snakey] Application already deployed. No need to reinstall.
[2012-04-26 21:57:02 - Mr.Snake.Framework] Could not find Mr.Snake.Framework.apk!
[2012-04-26 21:57:02 - Mr.Snake] Could not find Mr.Snake.apk!
[2012-04-26 21:57:02 - Mr.Snakey] Starting activity com.zardtechnologies.mrsnakey.MrSnakey on device emulator-5554
[2012-04-26 21:57:04 - Mr.Snakey] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.zardtechnologies.mrsnakey/.MrSnakey }
[2012-04-26 21:57:04 - Mr.Snakey] ActivityManager: Warning: Activity not started, its current task has been brought to the front
[2012-04-26 21:58:20 - Mr.Snakey] ------------------------------
[2012-04-26 21:58:20 - Mr.Snakey] Android Launch!
[2012-04-26 21:58:20 - Mr.Snakey] adb is running normally.
[2012-04-26 21:58:20 - Mr.Snakey] Performing com.zardtechnologies.mrsnakey.MrSnakey activity launch
[2012-04-26 21:58:20 - Mr.Snakey] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Test.Phone'
[2012-04-26 21:58:22 - Mr.Snakey] Application already deployed. No need to reinstall.
[2012-04-26 21:58:22 - Mr.Snakey] Project dependency found, installing: Mr.Snake.Framework
[2012-04-26 21:58:22 - Mr.Snake.Framework] Uploading Mr.Snake.Framework.apk onto device 'emulator-5554'
[2012-04-26 21:58:25 - Mr.Snake.Framework] Installing Mr.Snake.Framework.apk...
[2012-04-26 21:58:52 - Mr.Snake.Framework] Success!
[2012-04-26 21:58:52 - Mr.Snake.Framework] Project dependency found, installing: Mr.Snake
[2012-04-26 21:58:52 - Mr.Snake] Uploading Mr.Snake.apk onto device 'emulator-5554'
[2012-04-26 21:58:54 - Mr.Snake] Installing Mr.Snake.apk...
[2012-04-26 21:59:16 - Mr.Snake] Success!
[2012-04-26 21:59:16 - Mr.Snakey] Project dependency found, installing: Mr.Snake
[2012-04-26 21:59:18 - Mr.Snake] Application already deployed. No need to reinstall.
[2012-04-26 21:59:18 - Mr.Snakey] Starting activity com.zardtechnologies.mrsnakey.MrSnakey on device emulator-5554
[2012-04-26 21:59:20 - Mr.Snakey] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.zardtechnologies.mrsnakey/.MrSnakey }
[2012-04-26 21:59:20 - Mr.Snakey] ActivityManager: Warning: Activity not started, its current task has been brought to the front

My Mr.Snakey Activity file is here: 我的Mr.Snakey活动文件在这里:

package com.zardtechnologies.mrsnakey;

import com.zardapps.framework.Screen;
import com.zardtechnologies.androidgames.framework.impl.AndroidGame;

public class MrSnakey extends AndroidGame {

    public Screen getStartScreen() {
        return new LoadingScreen(this);
    }




}

It links the file from the AndroidGame , which is located at framework impl project: 它从位于框架impl项目中的AndroidGame链接文件:

package com.zardtechnologies.androidgames.framework.impl;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.view.Window;
import android.view.WindowManager;

import com.zardapps.framework.Audio;
import com.zardapps.framework.FileIO;
import com.zardapps.framework.Game;
import com.zardapps.framework.Graphics;
import com.zardapps.framework.Input;
import com.zardapps.framework.Screen;

public abstract class AndroidGame extends Activity implements Game {
    AndroidFastRenderView renderView;
    Graphics graphics;
    Audio audio;
    Input input;
    FileIO fileIO;
    Screen screen;
    WakeLock wakeLock;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
        int frameBufferWidth = isLandscape ? 480 : 320;
        int frameBufferHeight = isLandscape ? 320 : 480;
        Bitmap frameBuffer = Bitmap.createBitmap(frameBufferWidth,
                frameBufferHeight, Config.RGB_565);

        float scaleX = (float) frameBufferWidth
                / getWindowManager().getDefaultDisplay().getWidth();
        float scaleY = (float) frameBufferHeight
                / getWindowManager().getDefaultDisplay().getHeight();

        renderView = new AndroidFastRenderView(this, frameBuffer);
        graphics = new AndroidGraphics(getAssets(), frameBuffer);
        fileIO = new AndroidFileIO(getAssets());
        audio = new AndroidAudio(this);
        input = new AndroidInput(this, renderView, scaleX, scaleY);
        screen = getStartScreen();
        setContentView(renderView);

        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK,
                "GLGAME");

    }

    public void onResume() {
        super.onResume();
        wakeLock.acquire();
        screen.resume();
        renderView.resume();
    }

    public void onPause() {
        super.onPause();
        wakeLock.release();
        renderView.pause();
        screen.pause();

        if (isFinishing())
            screen.dispose();
    }

    public Input getInput() {
        return input;
    }

    public FileIO getFileIO() {
        return fileIO;
    }

    public Graphics getGraphics() {
        return graphics;
    }

    public Audio getAudio() {
        return audio;
    }

    public void setScreen(Screen screen) {
        if (screen == null)
            throw new IllegalArgumentException("Screen must not be null");
        this.screen.pause();
        this.screen.dispose();
        screen.resume();
        screen.update(0);
        this.screen = screen;
    }

    public Screen getCurrentScreen() {
        return screen;
    }
}

In which the game is from framework project 游戏来自框架项目

package com.zardapps.framework;
public interface Game {
    public Input getInput();
    public FileIO getFileIO();
    public Graphics getGraphics();
    public Audio getAudio();
    public void setScreen(Screen screen);
    public Screen getCurrentScreen();
    public Screen getStartScreen();
}

My Mr.Snakey Manifest : 我的斯纳基先生清单:

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

    <application
        android:debuggable="true"
        android:icon="@drawable/ic_launcher"
        android:label="Mr.Snakey" >
        <activity
            android:name=".MrSnakey"
            android:configChanges="keyboard|keyboardHidden|orientation"
            android:label="Mr.Snakey"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-sdk
        android:minSdkVersion="3"
        android:targetSdkVersion="12" />

</manifest>

Basically, I cant find the root of problem to the error; 基本上,我找不到错误的根源。 ActivityManager: Warning: Activity not started, its current task has been brought to the front I am currently using an emulator in eclipse. ActivityManager:警告:活动尚未启动,其当前任务已被置于最前面我目前在Eclipse中使用模拟器。 I have tried to rebuild my project , reinstall it and clean it but nothing works for me. 我试图重建我的项目,重新安装并清理它,但是对我没有任何帮助。 I appreciate the time you guys have taken to read such a long post I have written. 我感谢你们花时间阅读我写的这么长的帖子。

This is happened because there are no changes in the new APK file so try to clean the code or recompile it before running it again and this will go away. 发生这种情况是因为新APK文件中没有任何更改,因此请在再次运行之前尝试清除代码或重新编译该代码,否则该代码将消失。

If you are trying to run this game in the second time the Android OS will check the APK file if it has changes from the current one. 如果您尝试第二次运行该游戏,则Android操作系统将检查APK文件是否与当前文件相比有所更改。 and since the game already started the OS will not re-open the application. 并且由于游戏已经启动,因此操作系统将不会重新打开该应用程序。 he will just continue the already opened one. 他只会继续已经打开的那张。

the fastest solution for that is to press on the project name on the e-clipse and choose clean or rebuilt your application. 最快的解决方案是按电子剪辑上的项目名称,然后选择清理或重建应用程序。

This isn't an error or even a compiler warning that indicates you've done anything wrong. 这不是错误,甚至不是表明您做错了任何事情的编译器警告。 I know it says "warning", but it's more like an FYI. 我知道它说的是“警告”,但它更像是仅供参考。 As in "FYI, you're running the same code without changes, and that app is already running, so Android will just show you the running app instead of installing the same thing and restarting it." 与“ FYI中一样,您正在运行相同的代码而没有更改,并且该应用程序已经在运行,因此Android只会向您显示正在运行的应用程序,而不是安装相同的程序并重新启动它。”

I got the same error when i duplicated the same project. 复制相同的项目时出现相同的错误。 Initially i ran the duplicate project with tiny changes it successfully executed and shown on emulator later when i try to run the original project i got this error"Warning: Activity not started , its current task has been brought to the front" so i uninstalled the duplicate app from emulator by going through "Manage Apps" then i have run the original project it successfully run. 最初,我运行了重复的项目,并对其进行了微小的更改,并成功执行了该更改,并在稍后尝试运行原始项目时在模拟器上显示了该错误:“警告:活动未开始,其当前任务已移到最前面”,因此我卸载了通过“管理应用程序”从模拟器复制应用程序,然后我已经运行了它成功运行的原始项目。 Hope it may help u 希望对你有帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ActivityManager:警告:活动尚未开始,其当前任务已被置于最前面。 我读过的所有相关答案都没有收获。 - ActivityManager: Warning: Activity not started, its current task has been brought to the front. All the related answer I have read were not fruitful. jInternalFrame没有出现在最前面 - jInternalFrame not brought to the front Android,将已经开始的活动带回到最前面 - Android, bring already started activity back to front AppiumServerHasNotBeenStartedLocallyException: 本地 appium 服务器尚未启动 - AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started Android - 活动堆栈,将当前活动置于前面并禁用返回键 - Android - Activity stacks, bringing current activity to front and disabling back key 奇怪的行为:首次使用FLAG_ACTIVITY_NEW_TASK启动时,活动无法重新开始 - Weird behaviour : Activity not getting started again when first started with FLAG_ACTIVITY_NEW_TASK 当按下按钮时,它将被带到另一个按钮的前面 - When press the button, it will be brought to front of another button 执行在同一活动的先前实例中启动的AsyncTask剩余任务 - Perform remaining task of AsyncTask that was started in previous instance of the same activity 活动在fragmenttransaction.commit上已被破坏 - Activity has been destroyed on fragmenttransaction.commit ActivityNotFoundException:但已在清单中声明了活动 - ActivityNotFoundException: but activity has been declared in manifest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM