2

エミュレータで実行すると強制終了する理由がわかりません。私はスプラッシュスクリーンを作成しましたが、問題はありませんが、それは渡されません:

public class MainActivity extends Activity 
{
protected boolean _active = true;
protected int _splashTime = 5000;

// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // thread for displaying the SplashScreen
    Thread splashTread = new Thread() 
    {
        @Override
        public void run() 
        {
            try 
            {
                int waited = 0;
                while(_active && (waited < _splashTime)) 
                {
                    sleep(100);
                    if(_active) 
                    {
                        waited += 100;
                    }
                }
            } 
            catch(InterruptedException e) 
            {
                // do nothing
            } 
            finally 
            {
                finish();
                startActivity(new Intent("com.example.textsmslock.EnableActivity"));
                stop();
            }
        }
    };
    splashTread.start();
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        _active = false;
    }
    return true;
}
}

スプラッシュ スクリーンの後、以下の別のアクティビティ コードに移動することになっています。

public class Enable extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_enable);
   // getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_enable, menu);
    return true;
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
public void EnableYes(View view)
{
    startActivity(new Intent("com.example.textsmslock.EnterPin"));
}
public void EnableNo(View view)
{

}

}

レッドログキャッツ

11-17 21:04:53.504: E/Zygote(32): setreuid() failed. errno: 2
11-17 21:05:00.924: E/Zygote(32): setreuid() failed. errno: 17
11-17 21:05:02.074: E/BatteryService(58): usbOnlinePath not found
11-17 21:05:02.074: E/BatteryService(58): batteryVoltagePath not found
11-17 21:05:02.074: E/BatteryService(58): batteryTemperaturePath not found
11-17 21:05:02.094: E/SurfaceFlinger(58): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
11-17 21:05:07.994: E/EventHub(58): could not get driver version for /dev/input/mouse0, Not a typewriter
11-17 21:05:07.994: E/EventHub(58): could not get driver version for /dev/input/mice, Not a typewriter
11-17 21:05:08.653: E/System(58): Failure starting core service
11-17 21:05:08.653: E/System(58): java.lang.SecurityException
11-17 21:05:08.653: E/System(58):   at android.os.BinderProxy.transact(Native Method)
11-17 21:05:08.653: E/System(58):   at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
11-17 21:05:08.653: E/System(58):   at android.os.ServiceManager.addService(ServiceManager.java:72)
11-17 21:05:08.653: E/System(58):   at com.android.server.ServerThread.run(SystemServer.java:184)
11-17 21:05:09.293: E/SoundPool(58): error loading /system/media/audio/ui/Effect_Tick.ogg
11-17 21:05:09.304: E/SoundPool(58): error loading /system/media/audio/ui/KeypressStandard.ogg
11-17 21:05:09.304: E/SoundPool(58): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-17 21:05:09.304: E/SoundPool(58): error loading /system/media/audio/ui/KeypressDelete.ogg
11-17 21:05:09.304: E/SoundPool(58): error loading /system/media/audio/ui/KeypressReturn.ogg
11-17 21:05:35.019: E/AndroidRuntime(272): FATAL EXCEPTION: Thread-8
11-17 21:05:35.019: E/AndroidRuntime(272): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=this, com.example.textsmslock.Enable.class }
11-17 21:05:35.019: E/AndroidRuntime(272):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
11-17 21:05:35.019: E/AndroidRuntime(272):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
11-17 21:05:35.019: E/AndroidRuntime(272):  at android.app.Activity.startActivityForResult(Activity.java:2817)
11-17 21:05:35.019: E/AndroidRuntime(272):  at android.app.Activity.startActivity(Activity.java:2923)
11-17 21:05:35.019: E/AndroidRuntime(272):  at com.example.textsmslock.MainActivity$1.run(MainActivity.java:45)

**end of logcat**
4

3 に答える 3

0

Without a stacktrace its hard to tell, but most likely there is no Activity called EnableActivity. According to your code, the Activity is called Enable.

A Typesafe way to do this, is to not use Strings, but instead startActivity(new Intent(this, com.example.textsmslock.Enable.class))

于 2012-11-18T01:59:29.690 に答える
0

マニフェストにインテントフィルターがありませんでした

<intent-filter>
            <action android:name="com.example.textsmslock.Enable" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
于 2012-11-18T23:06:27.760 に答える
0

Activityまず、あなたは 2 番目の間違いを始めていると思います。MainActivityには、次のものがあります。

startActivity(new Intent("com.example.textsmslock.EnableActivity"));

次のようなものが必要な場合:

startActivity(new Intent(this, Enable.class));

次に、これはEnableマニフェストでどのように見えるかです。meta-dataタグで親アクティビティを示す必要はありません。

<activity android:name="com.example.textsmslock.Enable"
    android:label="@string/title_activity_enable"></activity>

第三に、人々が「スタック トレース」と言うとき、通常、Logcat では赤で表示されます。Exceptionまたはエラーがスローされたことを意味します。

于 2012-11-18T02:32:40.790 に答える