My application starts a service that keep running in background. Service class "ConnSrv" is not descriptive enough for users. How can I set service name that shown in OS taskmanager?
android:label generally controls the display names of components:
On an <activity>, it controls things like the caption associated with a launcher icon, or the default title in the action bar
On a <receiver>, it controls things like the display name of an app widget in the device's roster of available app widgets
On a <service>, it apparently covers how the service is named in the list of running services (I never tried this, which is why I started with a comment...)
On an <application>, not only does it control things like the name in the installed apps list in Settings, but it provides the default for all <activity>, <receiver>, and <service> elements that do not override it
Related
I am creating one custom dialer application in AOSP through Android.mk and I have also added following lines in my Android.mk file,
LOCAL_MODULE_NAME := MyDialer
LOCAL_OVERRIDES_PACKAGES :- Dialer
and building custom dialer application through this, but when I boot for the first time in settings application MyDialer is not selected by default, it will be none first then after user selects MyDialer manually then it will work, How should we set MyDialer as default dialer in system at the build time itself and avoid manual selection?
You have to ask in your application on first run to make it default app.
Check Answer Here
Replacing default Phone app on Android 6 and 7 with InCallService
There is a config.xml file in the Android build system for default dialer: packages/services/Telecomm/res/values/config.xml. Pls try to modify below items to point to your own dialer application:
<!-- Package name for the default in-call UI and dialer [DO NOT TRANSLATE] -->
<string name="ui_default_package" translatable="false">com.android.dialer</string>
<!-- Class name for the default in-call UI Service [DO NOT TRANSLATE] -->
<string name="incall_default_class" translatable="false">com.android.incallui.InCallServiceImpl</string>
<!-- Class name for the default main dialer activity [DO NOT TRANSLATE] -->
<string name="dialer_default_class" translatable="false">com.android.dialer.DialtactsActivity</string>
I want to change the name of the application which is defined in application tag like:
<application android:icon="#drawable/icon" android:label="#string/app_name">
Here the label is defined in resource xml, but what I want to achieve is that user input app_name of his choice and save it and then this new name should be used on Home or Launcher screen of device.
I know there is a way to do by using ActivityAlias but again the label is pre-defined and it's not a dynamic way to do it.
I read some articles that there are some apps like Magisk which changes it's app name & package name through user input.
I have enabled picture-in-picture mode for an Android TV app based on this guide: https://developer.android.com/guide/topics/ui/picture-in-picture.html
When I enter PiP mode, and navigate to the home screen of the Android home screen, it shown at the top the currently running task (PiP window) with an icon an title and options to Open and Close.
I could not find any documentation on how to set the the title and the icon (but most importantly the title). I have tried setting the ActivityManager.TaskDescription but without any luck. Also note that I do have an app title set in the Manifest, but that is not being shown here. Also note that in the task switcher, the app title and icon is shown correctly.
Any ideas how to set the (No title program) from the screenshot?
Tested on Android TV API 26, 27, as Picture-in-Picture is only available since Oreo.
If you implement MediaSession, the title will appear. The system evaluates the MediaSession similar to how notifications with MediaSession work on phones.
There is an activity that demonstrates how MediaSession can affect PIP actions in the android-PictureInPicture sample. This is a bug in the sample, thank you for logging it.
To get the title to appear, you will need to update the meta data on the media session.
MediaMetadataCompat metadata = new MediaMetadataCompat.Builder()
.putString(
MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE,
"Big Buck Bunny")
...
.build();
mSession.setMetadata(metadata);
Background
Android M presents a new way to handle selected text (link here), even from outside of your app . Text selection can be handled as such:
I know it's possible to handle the selected text from outside the app, because if I go to the web browser (or any other place that allows text selection), I can see that I can use the "API demos" app to handle the selected text.
The problem
I can't see a lot of information about how to do it.
The question
What should be added in code (and manifest) to be able to handle the selected text from outside the app ?
Is it possible to limit the selection to certain types of texts ? For example, offer to show the app only if the text type is a valid phone number ?
First, to clarify the question: On an M emulator, if you highlight text, you will see the new floating action mode. If you click the overflow icon, you will see "API DEMOS" show up:
Clicking that brings up an activity from the API Demos app, showing the highlighted text:
Replacing the value in the field and clicking the button puts your replacement text in as a replacement for whatever you had highlighted.
WARNING: The following explanation is from inspecting the API Demos code and the M Developer Preview documentation. It is very possible that this will change before M ships for realz. YMMV, unless you use the metric system, in which case YKMV.
The activity in question, that is receiving the text, supports ACTION_PROCESS_TEXT as the Intent action. EXTRA_PROCESS_TEXT will hold some text, or EXTRA_PROCESS_TEXT_READONLY will hold it if the text is read-only. The activity will be invoked via startActivityForResult(). The result Intent can have its own EXTRA_PROCESS_TEXT value, which will be the replacement text.
So, to the specific questions:
What should be added in code (and manifest) to be able to handle the selected text from outside the app ?
See above. Note that the API Demos activity (ProcessText) has this <intent-filter>:
<intent-filter >
<action android:name="android.intent.action.PROCESS_TEXT"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
The documentation does not discuss a MIME type. I have not run any experiments to determine if the MIME type is required, and what else we might get (text/html for stuff that has spans?).
Is it possible to limit the selection to certain types of texts ? For example, offer to show the app only if the text type is a valid phone number ?
That wouldn't seem to be possible given the documentation. That being said, it's certainly a reasonable idea (e.g., advertise a regex, or multiple regexes, via metadata in the manifest that the text must match).
This article on Android Developers Blog may be relevant, it describes how Google Translate option can be added to overflow text selection menu.
Android apps that use Android text selection behavior will already
have this feature enabled, so no extra steps need to be taken.
Developers who created custom text selection behavior for their apps
can easily implement this feature by following the below steps:
Scan via the PackageManager through all packages that have the
PROCESS_TEXT intent filter (for example:
com.google.android.apps.translate - if it installed) and add them as
MenuItems into TextView selections for your app
To query the package manager, first build an intent with the action
Intent.ACTION_PROCESS_TEXT, then retrieve the supported activities
and add an item for each retrieved activity and attach an intent to it
to launch the action
public void onInitializeMenu(Menu menu) {
// Start with a menu Item order value that is high enough
// so that your "PROCESS_TEXT" menu items appear after the
// standard selection menu items like Cut, Copy, Paste.
int menuItemOrder = 100;
for (ResolveInfo resolveInfo : getSupportedActivities()) {
menu.add(Menu.NONE, Menu.NONE,
menuItemOrder++,
getLabel(resolveInfo))
.setIntent(createProcessTextIntentForResolveInfo(resolveInfo))
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
}
I've noticed that the appearience of Dropbox shortcut-like widget to specified folder is consistent with shortcut layout no matter which launcher we use:
So I want to make such a widget that behaves and looks like shortcut and is consistent with user's launcher.
Is it possible to get the shortcut layout of Launcher and use it in our own widget?
Aside from AppWidgets, Android also has a concept of Launcher Shortcuts that are often grouped under the "Widget" label. That Dropbox folder is a Launcher Shortcut.
Shortcuts are simple, all data (icon, label, intent) is static, determined at creation time. They can't be updated dynamically, or resized, or scroll. But they match the launcher styling (and can be placed inside folders or the dock) and use less resources than AppWidgets.
Sadly they're poorly documented. You can find a sample in the ApiDemos/src/com/example/android/apis/app/LauncherShortcuts.java ( https://android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/app/LauncherShortcuts.java ) and references to them at https://developer.android.com/reference/android/content/Intent.html#EXTRA_SHORTCUT_ICON (all the EXTRA_SHORTCUT_... items).
You need an Activity and AndroidManifest intent-filter to handle creating the shortcuts:
AndroidManifest.xml
<activity
android:name=".LauncherShortcutActivity" >
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
This activity will be called by the launcher with startActivityForResult, you may present an interface (for example let the user select a folder the shortcut should be to) but ultimately must return an icon, label and intent to the launcher.
void setResult(CharSequence title, int iconResourceId, Intent targetIntent) {
Intent data = new Intent();
data.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, iconResourceId));
data.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
data.putExtra(Intent.EXTRA_SHORTCUT_INTENT, targetIntent);
setResult(Activity.RESULT_OK, data);
finish();
}
In this case, the icon is specified as a resource of my app. Alternatively the icon can be a bitmap (for example a contact photo):
data.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
Is it possible to get the shortcut layout of Launcher and use it in our own widget?
There are hundreds of home screen implementations. Home screen developers can do whatever they want:
They do not have to support app widgets
They do not have to support shortcuts
They do not have to have the ability to launch an app (e.g., single-purpose devices, like kiosks)
They do not have to show icons for shortcuts or launcher entries
They do not have to use text captions for shortcuts or launcher entries
They do not have to have icons and text captions vertically stacked for shortcuts or launcher entries
Etc.
You are certainly welcome to examine various open source home screen implementations and see how they format their launcher entries. However, there is no universal way of determine if they support shortcuts or launchers, let alone how they format those sorts of entries.