飞溅和主要活动的错误 [英] Splash and main activity error

查看:110
本文介绍了飞溅和主要活动的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否有人请帮助。飞溅活动后,主要的活动是不开放的。但是,如果我把在其他任何意图过滤器的名称,它工作得并不是主要活动。在此先感谢!

SPLASH活动:

 包com.hellhog.tfreqpro;进口android.app.Activity;
进口android.content.Intent;
进口android.media.MediaPlayer;
进口android.os.Bundle;
进口android.view.Window;
进口android.view.WindowManager;公共类飞溅延伸活动{@覆盖
保护无效的onCreate(捆绑savedInstanceState){
    // TODO自动生成方法存根
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)。
    的setContentView(R.layout.splash);    MediaPlayer的MP = MediaPlayer.create(Splash.this,R.raw.smusic);
    mp.start();    线程亲=新主题​​(){
        公共无效的run(){
            尝试{
                睡眠(6000);
            }赶上(InterruptedException的E){
                e.printStackTrace();
            }最后{
                意图哟=新意图(android.intent.action2.MAINACTIVITY);
                startActivity(哟);
            }
        }
    };    pro.start();
}@覆盖
保护无效的onPause(){
    // TODO自动生成方法存根
    super.onPause();
    完();
}}

主要活动:

 包com.hellhog.tfreqpro;进口android.os.Bundle;
进口android.app.Activity;
进口android.content.Intent;
进口android.view.Menu;
进口android.view.View;
进口android.view.Window;
进口android.view.WindowManager;
进口android.widget.Button;公共类MainActivity延伸活动{按钮A,C;
意向B,D;
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)。
    的setContentView(R.layout.activity_main);    A =(按钮)findViewById(R.id.tacan);
    C =(按钮)findViewById(R.id.flp);    a.setOnClickListener(新View.OnClickListener(){        @覆盖
        公共无效的onClick(查看为arg0){
            // TODO自动生成方法存根
            B =新意图(android.intent.action.CONVERTER);
            startActivity(二);
        }
    });    c.setOnClickListener(新View.OnClickListener(){        @覆盖
        公共无效的onClick(视图v){
            // TODO自动生成方法存根
            D =新意图(android.intent.action.NEWFLP);
            startActivity(四);
        }
    });}@覆盖
公共布尔onCreateOptionsMenu(菜单菜单){
    //充气菜单;如果是present这增加了项目操作栏。
    。getMenuInflater()膨胀(R.menu.main,菜单);
    返回true;
}
}

清单:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=com.hellhog.tfreqpro
安卓版code =1
机器人:=的versionName1.0><用途-SDK
    安卓的minSdkVersion =8
    机器人:targetSdkVersion =10/><应用
    机器人:allowBackup =真
    机器人:图标=@绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme>
    <活动
        机器人:名字=com.hellhog.tfreqpro.Splash
        机器人:标签=@字符串/ APP_NAME
        机器人:screenOrientation =风景>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>
            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;
    <活动
        机器人:名字=com.hellhog.tfreqpro.MainActivity
        机器人:标签=@字符串/ APP_NAME
        机器人:screenOrientation =肖像>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action2.MAINACTIVITY/>
            <类机器人:名字=android.intent.category.DEFAULT/>
        &所述; /意图滤光器>
    < /活性GT;
    <活动
        机器人:名字=com.hellhog.tfreqpro.Converter
        机器人:标签=@字符串/ APP_NAME
        机器人:screenOrientation =肖像>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.CONVERTER/>
            <类机器人:名字=android.intent.category.DEFAULT/>
        &所述; /意图滤光器>
    < /活性GT;
    <活动
        机器人:名字=com.hellhog.tfreqpro.Flightplan
        机器人:标签=@字符串/ APP_NAME
        机器人:screenOrientation =肖像>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.FLIGHTPLAN/>
            <类机器人:名字=android.intent.category.DEFAULT/>
        &所述; /意图滤光器>
    < /活性GT;
    <活动
        机器人:名字=com.hellhog.tfreqpro.NewFLP
        机器人:标签=@字符串/ APP_NAME
        机器人:screenOrientation =肖像>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.NEWFLP/>
            <类机器人:名字=android.intent.category.DEFAULT/>
        &所述; /意图滤光器>
    < /活性GT;
< /用途>< /清单>


解决方案

在您的飞溅的活动试试这个..

 意图哟=新意图(Splash.this,MainActivity.class);
        startActivity(哟);

在您的清单文件

 <活动
    机器人:名字=com.hellhog.tfreqpro.MainActivity
    机器人:标签=@字符串/ APP_NAME
    机器人:screenOrientation =肖像>
    &所述;意图滤光器>
        <作用机器人:名字=android.intent.action2.MAINACTIVITY/>
        <类机器人:名字=android.intent.category.DEFAULT/>
    &所述; /意图滤光器>
< /活性GT;

删除意图以下行filtter

 <意向滤光器>
        <作用机器人:名字=android.intent.action2.MAINACTIVITY/>
        <类机器人:名字=android.intent.category.DEFAULT/>
    &所述; /意图滤光器>

Can someone please help. After the splash activity, the main activity isn't opening up. But if I put in any other intent filter name it works Just not the main activity. Thanks in advance!

SPLASH ACTIVITY:

package com.hellhog.tfreqpro;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class Splash extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.splash);

    MediaPlayer mp = MediaPlayer.create(Splash.this, R.raw.smusic);
    mp.start();

    Thread pro = new Thread(){
        public void run(){
            try{
                sleep(6000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }finally{
                Intent yo = new Intent ("android.intent.action2.MAINACTIVITY");
                startActivity(yo);
            }
        }
    };

    pro.start();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    finish();
}

}

MAIN ACTIVITY:

package com.hellhog.tfreqpro;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class MainActivity extends Activity{

Button a, c;
Intent b, d;
@Override
protected 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_main);

    a= (Button) findViewById(R.id.tacan);
    c= (Button) findViewById(R.id.flp);

    a.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            b = new Intent ("android.intent.action.CONVERTER");
            startActivity(b);
        }
    });

    c.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            d = new Intent ("android.intent.action.NEWFLP");
            startActivity(d);
        }
    });

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
}

MANIFEST:

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="10" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.hellhog.tfreqpro.Splash"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.hellhog.tfreqpro.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action2.MAINACTIVITY" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.hellhog.tfreqpro.Converter"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.CONVERTER" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.hellhog.tfreqpro.Flightplan"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.FLIGHTPLAN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.hellhog.tfreqpro.NewFLP"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.NEWFLP" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>        
</application>

</manifest> 

解决方案

Try this in your Splash Activity..

 Intent yo = new Intent (Splash.this, MainActivity.class);
        startActivity(yo);

In your manifest file

<activity
    android:name="com.hellhog.tfreqpro.MainActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait" >
    <intent-filter>
        <action android:name="android.intent.action2.MAINACTIVITY" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

delete the following lines of intent filtter

 <intent-filter>
        <action android:name="android.intent.action2.MAINACTIVITY" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>

这篇关于飞溅和主要活动的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆