1
在機器人顯影劑網站,應用插件被實現爲以下的組合:什麼使apk成爲一個'小部件'?
- AppWidgetProviderInfo對象
- 的AppWidgetProvider類
- 初始視圖佈局
在AndroidManifest所示的應用程序窗口小部件的一個典型的例子.xml是:
<receiver android:name="ExampleAppWidgetProvider" > // item '2'
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/example_appwidget_info" /> // item '1'
</receiver>
和項目「1」常常形容這裏的項目「3」是:
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dp"
android:minHeight="72dp"
android:updatePeriodMillis="86400000"
android:previewImage="@drawable/preview"
android:initialLayout="@layout/example_appwidget" // item '3'
android:configure="com.example.android.ExampleAppWidgetConfigure"
android:resizeMode="horizontal|vertical">
</appwidget-provider>
我見過很多的應用程序插件的例子是這樣的。
但是我還是不明白什麼簽名「AppWidget框架」使用發現手機上的所有應用程序窗口部件,並把他們在「小工具」選項卡中的主菜單。
要使應用在主菜單中的'所有應用'選項卡中顯示,您可以在其下面添加其活動的意圖過濾器之一。
<category android:name="android.intent.category.LAUNCHER" />
然而,有什麼相應的魔法關鍵字的應用程序窗口小部件?啓動程序如何識別應用程序窗口小部件並將其置於'窗口小部件'選項卡下?
我知道這可能不是因爲項目1,2,3的簽名,因爲我遇到了別人開發的舊應用小部件,而我看不到1,2,3模式。我不知道'AppWidget框架'如何能夠找出它是一個應用程序部件。
我列出下面的舊應用程序小部件的清單文件,如果你能指出我應該在哪裏尋找線索,我會非常感激。
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.weather">
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:process="com.example.weather.sinaweather"
android:label="@string/app_name"
android:icon="@drawable/widget_weather_icon">
<provider
android:name=".provider.WeatherProvider"
android:authorities="com.example.weather" />
<activity
android:name=".WeatherDetail"
android:excludeFromRecents="true">
</activity>
<activity
android:name=".WeatherDetailActivity"
android:launchMode="singleTop"
android:excludeFromRecents="true"
android:configChanges="orientation|screenSize|keyboardHidden|navigation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AlertActivity"
android:excludeFromRecents="true"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<!--action android:name="android.intent.action.MAIN" /-->
<!--category android:name="android.intent.category.LAUNCHER" /-->
</intent-filter>
<intent-filter>
<action android:name="com.example.weather.action.START_WEATHER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.example.weather.action.START_WEATHER_APPLICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".WeatherDisplayCurrentDialog"
android:excludeFromRecents="true"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="com.example.weather.DISPLAY_CURRENT_CONFIGURE" />
</intent-filter>
</activity>
<activity
android:name=".AddCityActivity"
android:excludeFromRecents="true"
android:configChanges="orientation|screenSize|keyboardHidden|navigation|locale">
<intent-filter>
<action android:name="com.example.weather.action.START_WEATHER_SETTINGS_INTELNAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".SearchCityActivity"
android:excludeFromRecents="true"
android:configChanges="orientation|screenSize|keyboardHidden|navigation">
</activity>
<service android:name=".WeatherService">
<intent-filter>
<action android:name="com.example.weather.INIT_APP" />
<action android:name="com.example.weather.WEATHER_RETRY" />
<action android:name="com.example.weather.RESET_AUTO_UPDATE_ALARM" />
<action android:name="com.example.weather.WEATHER_AUTOUPDATE" />
<action android:name="com.example.weather.action.NEED_WEATHER_INFO" />
<action android:name="com.example.weather.action.TOP_CITY_CHANGED" />
<action android:name="com.example.weather.LOCATION_UPDATE" />
</intent-filter>
</service>
<receiver
android:name=".WeatherReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="com.example.weather.RESTART_SERVICE" />
</intent-filter>
</receiver>
</application>
</manifest>