In android developer website, app widget is implemented as a combination of:
AppWidgetProviderInfo object
AppWidgetProvider class
Initial view layout
A typical example of app widget shown in AndroidManifest.xml is:
<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>
And item '1' often describe where item '3' is:
<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>
I've seen many app widget examples like this.
However i still don't understand what signature 'AppWidget framework' use to find all app widgets on the phone and put them under 'Widgets' tab in main menu.
To enable app to be shown under 'All apps' tab in main menu, you can add below to one of its activity's intent filter.
<category android:name="android.intent.category.LAUNCHER" />
however, what are the corresponding magic keywords for app widget? How does launcher recognize an app widget and put it under 'Widgets' tab?
I know it's probably NOT because of the item 1,2,3 signature, 'cause i came across an old app widget that someone else developed, and i can not see the 1,2,3 pattern. And i have no idea how 'AppWidget framework' can figure out it's a app widget.
I list the old app widget's manifest file below, if you can point out where should i look for clues, i'll really appreciate it.
<?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>
Read this article for detailed instructions on creating and declaring a widget. What you call the '1-2-3' pattern is required in manifest.
Related
I am developing a Launcher app for Android TV and want to override the functionality of Home button. I want to bring my Application's Activity to top when Home button is pressed so that it acts as default launcher. I tried this Android Studio TV remote buttons but did not work. It is definitely possible because there are button mapper apps on the PlayStore. I have this in my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_TV_LISTINGS" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.action.LAUNCHER" />
</intent>
</queries>
<application
android:name=".AppName"
android:allowBackup="true"
android:banner="#mipmap/ic_launcher_round"
android:fullBackupContent="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/Theme.AppTheme">
<activity
android:name=".AppActivity"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTask"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER_APP" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
</activity>
<receiver
android:name=".broadcast_receivers.PackageChangeReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
any leads are appreciated. Thanks.
i am working on an app in witch i am performing two launches from one installation. my both launcher are working fine for there separate individual tasks.
but my problem is: i am getting same name or same icon for both launcher.
i want two different icon and name for both launchers.
this is my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.androidhive.awesomewallpapers"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Start Wallpaper App -->
<application
android:name="info.androidhive.awesomewallpapers.app.AppController"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/FreeWallTheme" >
<activity
android:name="info.androidhive.awesomewallpapers.SplashActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="info.androidhive.awesomewallpapers.MainActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="info.androidhive.awesomewallpapers.FullScreenViewActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="info.androidhive.awesomewallpapers.SettingsActivity"
android:label="#string/action_settings"
android:screenOrientation="portrait" >
</activity>
<!-- End Wallpaper App -->
<!-- Start Crop App -->
<activity
android:name="info.androidhive.awesomewallpapers.CropWallpaper.FolderListScreen"
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|fontScale|screenSize"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<activity
android:name="info.androidhive.awesomewallpapers.CropWallpaper.ImageListScreen"
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|fontScale|screenSize"
android:label="#string/app_name" >
</activity>
<activity
android:name="info.androidhive.awesomewallpapers.CropWallpaper.MyPrefScreen"
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|fontScale"
android:label="#string/app_name" >
</activity>
<activity
android:name="info.androidhive.awesomewallpapers.CropWallpaper.CropWallpaper"
android:configChanges="keyboard|keyboardHidden|fontScale"
android:label="#string/app_name"
android:process=":CropWallpaper" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<!--End Crop App -->
</application>
</manifest>
as the document says, you can provide android:icon attribute in activity tag for the two launchers. It will override that provided in application tag. And for the name of launcher, just set android:label to different string resource.
Currently you only provide an Icon in application tag and android:label for the two activities are the same resource, so you will see same icon and same label.
I'm using worklight for my mobile app project. My question is how to disable splash screen in android manifest?
This is my android manifest.
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rmbp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- Push permissions -->
<permission
android:name="com.rmbp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.rmbp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:debuggable="true"
android:icon="#drawable/icon"
android:label="#string/app_name" >
<activity
android:name="com.rmbp.rmbp"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.rmbp.rmbp.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Preference Activity -->
<activity
android:name="com.worklight.common.WLPreferences"
android:label="Worklight Settings" >
</activity>
<!-- Push service -->
<!--
In order to use the c2dm library, an application must declare a class with the name C2DMReceiver, in its own package, extending com.google.android.c2dm.C2DMBaseReceiver
It must also include this section in the manifest, replacing "com.google.android.apps.chrometophone" with its package name.
-->
<service android:name="com.rmbp.GCMIntentService" />
<service android:name="com.rmbp.ForegroundService" />
<!-- Only google service can send data messages for the app. If permission is not set - any other app can generate it -->
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.rmbp" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.rmbp" />
</intent-filter>
</receiver>
</application>
</manifest>
Check my repo: https://github.com/datomnurdin/worklight-mobile
Thanks a lot in advance.
Move this block:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.rmbp.rmbp.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
to the activity which you want to start first. Intent filter will mark this activity as default for start from launcher.
For example:
<activity
android:name="com.rmbp.SplashScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_splash_screen"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.rmbp.rmbp"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.rmbp.rmbp.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I have some intents to execute different activities, my problem is that when I run the app in the device, eclipse install it with the name of the last activity. For example:
We have, three activities: 1 - 2 - 3. The first is the main activity (1), it name is Noow but I have an Intent to another activity (3) to get the location and return the data to (1). The app installed is named as getLocation (3) and it must have the name of the (1).
This is the manifiest xml file. Could someone help me with this? Thanks
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="victor.martin.noow"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
<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_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="victor.martin.noow.SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="victor.martin.noow.LoginScreen"
android:label="#string/title_activity_login_screen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="victor.martin.noow.MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="victor.martin.noow.getLocationActivity"
android:label="#string/getLocationActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is happening because the SDK will use the name of the activity having the LAUNCHER property:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The simplest solution would be to delete the LoginScreenActivity label and set it programatically. In this case the label provided in the tag will be used.
First of all there has to be one activity set as main activity i.e launcher activity. What you have done is set all activities as main which is incorrect in all terms of programming logic.
The activity with
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
gets the by default name, and by convention in your case after reading your xml the last activity got default name.
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>