清单文件中的intent-filter以在安装时启用打开按钮

时间:2013-03-13 19:21:39

标签: android android-intent xamarin.android

我对Android开发相当陌生,我看过将其放入Manifest.xml文件的示例:

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

我认为这是我需要的,所以在我的应用程序安装后,将启用打开按钮。但是,即使我在我的Manifest中有这个按钮也会被禁用。

那么,谁能告诉我,我做错了?

感谢您的帮助。

**更新......

这是我的完整Manifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" 
            android:versionName="1.1" package="com.MyAppName.app">
    <uses-sdk android:minSdkVersion="8" targetSdkVersion="10" />

    <uses-library android:name="com.google.android.maps" />

    <uses-feature android:glEsVersion="0x00020000" android:required="true" />

    <permission android:name="com.MyAppName.app.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
    <permission android:name="com.MyAppName.app.permission.C2D_MESSAGE" android:protectionLevel="signature" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="com.MyAppName.app.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.MyAppName.app.permission.MAPS_RECEIVE" />

    <application android:label="@string/MyAppName" android:theme="@android:style/Theme.NoTitleBar" android:icon="@drawable/Icon">
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_KEY" />
    </application>
</manifest>

**更新

以下是活动的代码:

using System;
using Android.App;
using Android.Content;
using Android.OS;

namespace MyApp
{
    [Activity (Label = "MyApp", MainLauncher = true, Theme="@style/Theme.Splash", NoHistory = true)]
    public class SplashActivity : Activity
    {
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            Android.OS.SystemClock.Sleep(2000);

            // Start our real activity
            StartActivity (typeof (Activity1));
        }
    }
}

1 个答案:

答案 0 :(得分:0)

意图过滤器必须如下所示,在主Activity <activity>元素中:

    <activity
        android:name=".<your activity name>"
        android:label="My App" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>