intent-filter in manifest file to enable the open button on install

我是研究僧i 提交于 2019-12-24 12:35:13

问题


I am fairly new to Android Development and I have seen examples where this is put into the Manifest.xml file:

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

I thought this was what I needed so that after my Application Installs the open button would be enabled. However, even though Ihave this in my Manifest the button is stlll disabled.

So, can anyone tell me ehat I am doing wrong?

Thanks for any help.

** UPDATE...

Here is my full Manifest.xml file:

<?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>

** UPDATE

Here is the code for the activity:

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:


The intent filter must be as follows, in the main Activity's <activity> element:

    <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>


来源:https://stackoverflow.com/questions/15394558/intent-filter-in-manifest-file-to-enable-the-open-button-on-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!