【问题标题】:Installation only as a widget not as an app仅作为小部件而非应用程序安装
【发布时间】:2018-10-22 17:30:17
【问题描述】:

我必须确保安装只是作为一个小部件而不是作为一个应用程序,所以它不应该出现在应用程序之间。

这是清单文件,考虑到我必须保留用于配置小部件的活动.WidgetConfigureActivity。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.widgettwitter">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

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

        <receiver android:name=".WidgetProvider">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                <action android:name="com.widgettwitter.WIDGET_REFRESH" />
            </intent-filter>

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_info" />
        </receiver>

        <service
            android:name=".WidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS" />
        <service android:name="com.widgettwitter.TwitterService" />

    </application>

</manifest>

【问题讨论】:

  • 删除这个“
  • @W0rmH0le:我试过了,但是当我尝试从以下问题编译时: 运行“应用程序”时出错:找不到默认活动
  • 这是因为 Android Studio 正在尝试“启动默认活动”。转到:运行 -> 编辑配置 -> 启动选项并选择“无”。这样,Android Studio 只会安装应用,不会尝试启动任何活动
  • 谢谢,你是安卓的专家吗?
  • 不.. 我不是,很遗憾.. 我只是知道如何从应用程序托盘“隐藏”应用程序。我将发布作为将来参考的答案。

标签: android widget android-widget android-manifest


【解决方案1】:

要从应用程序托盘中隐藏应用程序,您只需删除以下行:

<category android:name="android.intent.category.LAUNCHER"

由于您的应用没有要启动的“默认”活动,您可以将 Android Studio 配置为不执行任何操作或启动特定活动。

只需安装应用程序:

Run -> Edit Configurations -> Launch Options and select "Nothing".

根据需要开始特定活动:

Run -> Edit Configurations -> Launch Options -> Specified Activity and select the activity that you want.

这样做,您将能够使用 Android Studio 启动/安装您的应用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-25
    相关资源
    最近更新 更多