本文介绍了清单文件意图过滤器,以使安装打开按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新Android开发,我已经看到这何处投入Manifest.xml文件的例子:

 <意向滤光器>
    <作用机器人:名字=android.intent.action.MAIN/>`
&所述; /意图滤光器>

我想这是我所需要的,这样我的应用程序安装打开按钮将被启用了。不过,即使IHAVE这在我的清单按钮被禁用stlll

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

感谢您的帮助。

**更新...

下面是我的全Manifest.xml文件:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android安卓版code =1
            机器人:=的versionName1.1包=com.MyAppName.app>
    <采用-SDK安卓的minSdkVersion =8targetSdkVersion =10/>    <使用库机器人:名字=com.google.android.maps/>    <使用特征的android:glEsVersion =0x00020000机器人:所需=真/>    <允许机器人:名字=com.MyAppName.app.permission.MAPS_RECEIVE安卓的ProtectionLevel =签名/>
    <允许机器人:名字=com.MyAppName.app.permission.C2D_MESSAGE安卓的ProtectionLevel =签名/>    <使用许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION/>
    <使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/>
    <使用许可权的android:NAME =android.permission.CALL_PHONE/>
    <使用许可权的android:NAME =android.permission.GET_ACCOUNTS/>
    <使用许可权的android:NAME =android.permission.INTERNET对/>
    <使用许可权的android:NAME =android.permission.WAKE_LOCK/>
    <使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用许可权的android:NAME =com.google.android.c2dm.permission.RECEIVE/>
    <使用许可权的android:NAME =com.google.android.providers.gsf.permission.READ_GSERVICES/>
    <使用许可权的android:NAME =com.MyAppName.app.permission.C2D_MESSAGE/>
    <使用许可权的android:NAME =com.MyAppName.app.permission.MAPS_RECEIVE/>    <应用机器人:标签=@字符串/ MyAppName机器人:主题=@安卓风格/ Theme.NoTitleBar机器人:图标=@绘制/图标>
        <元数据机器人:名字=com.google.android.maps.v2.API_KEY机器人:值=MY_KEY/>
    < /用途>
< /清单>

**更新

下面是code的活动:

 使用系统;
使用Android.App;
使用Android.Content;
使用Android.OS;命名空间的MyApp
{
    [活动(标签=MyApp的,MainLauncher = TRUE,主题=@风格/ Theme.Splash,NoHistory = TRUE)]
    公共类SplashActivity:活动
    {
        保护覆盖无效的OnCreate(束束)
        {
            base.OnCreate(包);            Android.OS.SystemClock.Sleep(2000);            //开始我们真正的活动
            StartActivity(typeof运算(活动1));
        }
    }
}


解决方案

的意图过滤器必须如下所示,在主要活动的<活性GT; 元素:

 <活动
        机器人:名字=<您的活动名称方式>
        机器人:标签=我的应用>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;

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));
        }
    }
}
解决方案

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>

这篇关于清单文件意图过滤器,以使安装打开按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 00:55