这是我的第一个问题,我已经找到了答案,但我找不到答案。 我的应用程序以SplashScreen视频开始,视频完成后,活动尝试启动我的MainActivity,扩展了FragmentActivity。但是应用程序崩溃了以下日志:
05-17 11:32:56.554: W/Binder(476): Caught a RuntimeException from the binder stub implementation.
05-17 11:32:56.554: W/Binder(476): java.lang.NullPointerException
05-17 11:32:56.554: W/Binder(476): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
05-17 11:32:56.554: W/Binder(476): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
05-17 11:32:56.554: W/Binder(476): at android.os.Binder.execTransact(Binder.java:404)
05-17 11:32:56.554: W/Binder(476): at dalvik.system.NativeStart.run(Native Method)
05-17 11:32:56.554: W/InputMethodManagerService(360): Got RemoteException sending setActive(false) notification to pid 1075 uid 10052
05-17 11:32:56.574: W/IInputConnectionWrapper(514): showStatusIcon on inactive InputConnection
这是我的SplashScreen类的样子:
public class SplashScreen extends Activity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 6000;
public void Skip(View v) {
SPLASH_TIME_OUT = 0;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
VideoView mVideoView = (VideoView)findViewById(R.id.intro);
String uriPath = "android.resource://de.ebs_hannover.sean.elsaapp/"+R.raw.intro_vid;
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashScreen.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
这是我的MainActivity:
public class MainActivity extends FragmentActivity{
ViewPager viewPager=null;
TextView cPosTxt =null;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.activity_main);
cPosTxt = (TextView) findViewById(R.id.cPosTxt);
viewPager= (ViewPager) findViewById(R.id.pager);
FragmentManager fragmentManager=getSupportFragmentManager();
viewPager.setAdapter(new MyAdapter(fragmentManager));
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int arg0) {
if(arg0==0) {
cPosTxt.setText(R.string.menue);
}
if (arg0==1) {
cPosTxt.setText(R.string.btn_jubi);
}
if (arg0==2) {
cPosTxt.setText(R.string.btn_info);
}
if (arg0==3) {
cPosTxt.setText(R.string.btn_story);
}
if (arg0==4) {
cPosTxt.setText(R.string.btn_events);
}
if (arg0==5) {
cPosTxt.setText(R.string.btn_current);
}
}
@Override
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
// TODO Auto-generated method stub
}
});
}
public void StroemClick(View v) {
viewPager.setCurrentItem(0, true);
}
public void JubiClick(View v) {
viewPager.setCurrentItem(1, true);
}
public void InfoClick(View v) {
viewPager.setCurrentItem(2, true);
}
public void StoryClick(View v) {
viewPager.setCurrentItem(3, true);
}
public void EventsClick(View v) {
viewPager.setCurrentItem(4, true);
}
public void CurrentClick(View v) {
viewPager.setCurrentItem(5, true);
}
}
class MyAdapter extends FragmentStatePagerAdapter {
public MyAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int arg0) {
Fragment fragment=null;
if(arg0==0){
fragment=new MenuFragment();
}
if(arg0==1) {
fragment=new JubiFragment();
}
if(arg0==2) {
fragment=new InfoFragment();
}
if(arg0==3){
fragment=new StoryFragment();
}
if(arg0==4){
fragment=new EventsFragment();
}
if(arg0==5){
fragment=new CurrentFragment();
}
return fragment;
}
@Override
public int getCount() {
return 6;
}
}
以防万一(因为我的建议可能是这个问题)这里是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.ebs_hannover.sean.elsaapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name="de.ebs_hannover.sean.elsaapp.SplashScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我做错了什么?没有SplashScreen在开始时它工作正常...所以当我将我的MainActivity设置为清单中的启动器活动...感谢您的帮助:)
答案 0 :(得分:1)
尝试在MainActivity
代码中添加<application>
类:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name="de.ebs_hannover.sean.elsaapp.SplashScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
// ADD ALL ACTIVITIES LIKE THIS:
<activity
android:name="de.ebs_hannover.sean.elsaapp.MainActivity"
android:label="@string/app_name" />
</application>