我无法更改应用程序的启动活动。在开始我的开始活动是com.example.image_changer.MainActivity
和这个我的应用程序正常运行。然后我将我的启动活动从MainActivity
更改为com.example.image_changer.Splash
。但我的应用程序不启动com.example.image_changer.Splash
活动。
我想com.example.image_changer.Splash
作为我的应用程序的开始活动。
我曾尝试以下解决方案:
1.在Eclipse中,我更改此设置:运行菜单 - >调试配置---->在我的应用程序---> Android的标签--->行动启动---->启动(单选按钮)---->选择(从下拉菜单中)--->com.example.image_changer.Splash
。
无法更改应用程序的启动活动 - Android
2.互联网搜索:
我已经试过此链接给所有的解决方案:Change application's starting activity
在这个环节zeh
(用户)发表评论,这可能看起来像同我的问题,但没有人提出更好的解决方案。
注意,当我运行我的程序,然后运行splash.java但不显示模拟器的屏幕上,我知道这是因为我的代码System.out.println();
在splash.java线程,它打印字符串在控制台每次当我运行我的应用程序。
那么如何解决这个问题呢?
这是我的清单:
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/imagechanger"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.image_changer.Splash"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.image_changer.MainActivity1"></activity>
<activity android:name="com.example.image_changer.GamesFragment"></activity>
<activity android:name="com.example.image_changer.MoviesFragment"></activity>
<activity android:name="com.example.image_changer.TabsPagerAdapter"></activity>
<activity android:name="com.example.image_changer.TopRatedFragment"></activity>
<activity android:name="com.example.image_changer.Imageswipe"></activity>
<activity android:name="com.example.image_changer.Mapview"></activity>
<activity
android:name="com.example.image_changer.MainActivity"
android:label="@string/app_name"></activity>
</application>
</manifest>
这是我Splash.java
类文件
package com.example.image_changer;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
public class Splash extends Activity {
/** Called when the activity is first created. */
private Thread mSplashThread;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
final Splash sPlashScreen = this;
// The thread to wait for splash screen events
mSplashThread = new Thread(){
@Override
public void run(){
try {
synchronized(this){
// Wait given period of time or exit on touch
wait(2500);
}
}
catch(InterruptedException ex){
}
// Run next activity
Intent intent = new Intent();
intent.setClass(sPlashScreen,MainActivity.class);
System.out.println("your are in the intent");
startActivity(intent);
finish();
}
};
mSplashThread.start();
}
/**
* Processes splash screen touch events
*/
@Override
public boolean onTouchEvent(MotionEvent evt)
{
if(evt.getAction() == MotionEvent.ACTION_DOWN)
{
synchronized(mSplashThread){
mSplashThread.notifyAll();
}
}
return true;
}
}
不工作,因为我无法为你张贴在这里'新的处理程序()使用处理器postDelayed(新的Runnable(){',当我将此代码日食给我一个错误';'或'}'missing。 –
回答更新,现在就试试!让我知道你是否仍然面临编译错误 –
好吧,兄弟它的工作,但还有一个问题,我需要再次使用这个线程'public boolean onTouchEvent(MotionEvent如何在方法中使用这个线程或处理程序 –