开发者

How to put widget and app in same apk?

开发者 https://www.devze.com 2023-03-28 02:20 出处:网络
I\'m trying to put a widget and an app in the same apk. Here\'s my manifest <manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"

I'm trying to put a widget and an app in the same apk.

Here's my manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.me.mywidget"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
   <activity android:name=".settingsPage"
              android:label="@string/app_name"
              android:theme="@style/app_theme"
              >
        <intent-filter>
            <action android:name="com.me.mywidget.SETTINGSPAGE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>
    <receiver android:name="MyWidgetProvider" android:label="My Widgets">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>
    <meta-data android:name="android.appwidget.provider"
        android:resource="@layout/widget_info" />
    </receiver>
    <service android:name=".UpdateWidgetService"></service>
    <activity android:name=".Test"></activity>
</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="7" />
</manifest>

How do I put an app 开发者_开发百科and market in the same apk? I tried this and while it runs, the app does not show up in the app drawer.

Also, when I add android:name=".mywidgets" my widget crashes when I run it.

Also, I will be adding multiple sizes to the widget later on.


You need to add the intent filter for launcher to whichever activity you want to show in the launcher...

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

So if .Test is your primary launching activity you would modify your manifest like below..

    <activity android:name=".Test"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
0

精彩评论

暂无评论...
验证码 换一张
取 消