【问题标题】:How to open an activity in a package subfolder from another activity?如何从另一个活动打开包子文件夹中的活动?
【发布时间】:2016-06-19 18:43:25
【问题描述】:

我的清单有问题。当我尝试打开第二个 Activity 时,我收到错误 android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION }

在下面找到我的 Manifest .xml 包含

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xxxxx.monapplication" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" >
<activity android:name="com.xxxxx.monapplication.application.Accueil" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity android:name="com.xxxxx.monapplication.application.OwnerRegistration" >
    <intent-filter>
        <action android:name="android.intent.action.APPLICATION.OWNERREGISTRATION" />
        <category android:name="android.intent.category.APPLICATION.DEFAULT" />
    </intent-filter>
</activity>

我打开第二个活动的代码部分

btnMel.setOnClickListener( new View.OnClickListener()
{
    @Override
    public void onClick(View v)
    {
        Intent i = new Intent("com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION");
        startActivity(i);
    }
} 

请帮我找出错误。

【问题讨论】:

  • 试试这个代码.. Intent myIntent = new Intent(YourActivity.this, OWNERREGISTRATION.class); startActivity(myIntent);
  • 谢谢。它有效
  • B Aristide 请接受我的回答....

标签: android android-activity


【解决方案1】:

您可以通过其类名调用活动,然后将您的自定义意图放入 setAction。

private String YOUR_ACTION = "com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION"

//uou can use this instead.
//Intent i = new Intent(this /* caller context */, OwnerRegistration.class);
Intent i = new Intent();
i.setAction(YOUR_ACTION);
startActivity(i);

【讨论】:

【解决方案2】:

试试这个代码..

Intent myIntent = new Intent(YourActivity.this, OWNERREGISTRATION.class); startActivity(myIntent); 

【讨论】:

    猜你喜欢
    • 2013-05-26
    • 2012-01-04
    • 1970-01-01
    • 2013-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多