无法通过意图开始活动:ActivityNotFoundException [英] Unable to start activity through intent: ActivityNotFoundException

查看:241
本文介绍了无法通过意图开始活动:ActivityNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我此活动中定义我的的Andr​​oidManifest.xml

 <活动
        机器人:名字=泼水节
        机器人:标签=@字符串/ APP_NAME
        机器人:noHistory =真正的>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>
            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;

当我试图调用它是这样的:

 意图splashActivity =新意图(android.intent.action.Splash);
mainAppContext.startActivity(splashActivity);

我得到:

  android.content.ActivityNotFoundException:无活动处理意向{行动= android.intent.action.Splash}

当我尝试以这种方式来启动它:

 意图splashActivity =新意图(android.intent.action.MAIN);
mainAppContext.startActivity(splashActivity);

它使用对话框与许多选项那里,像Play商店等开完成操作
请在开始本活动帮助。


解决方案

 意图splashActivity =新意图(android.intent.action.Splash);

没有 - 不 - 不!它应该给

 意图splashActivity =新意图(背景下,Splash.class);

如果您使用的行动 - 这似乎是你想要某种行动的活动,例如,在浏览器中查看网页。
在你的情况,你必须使用具体的活动,并将其设置为意图


 <作用机器人:名字=android.intent.action.MAIN/>

这个动作是不是为你的应用程序,它是需要Android的发射器,在您的应用程序来启动它找到活动

有关意向机构的官方文档

I have this Activity defined in my AndroidManifest.xml:

   <activity
        android:name=".Splash"
        android:label="@string/app_name"
        android:noHistory="true" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />    
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

When I am trying to call it in this way:

Intent splashActivity = new Intent("android.intent.action.Splash");
mainAppContext.startActivity(splashActivity);

I get:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.Splash }

And when I try to start it in this way:

Intent splashActivity = new Intent("android.intent.action.MAIN ");
mainAppContext.startActivity(splashActivity);

It open a Complete action using dialog with many options there like play store etc. Please help in starting this Activity.

解决方案

Intent splashActivity = new Intent("android.intent.action.Splash");

No-no-no! It should to

Intent splashActivity = new Intent(context, Splash.class);

If you use action - it seem that you want activity for some type of action, for example, view webpage on browser. In your situation you have to use concrete activity and set it to intent


<action android:name="android.intent.action.MAIN" />

this action is not for your app, it is needed to android's launcher, that find activity in your application to launch it

Official documentation about intent mechanism

这篇关于无法通过意图开始活动:ActivityNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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