How to change default dialer application in AOSP? - android

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>

Related

Android: how to update app's label dynamically

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.

Set default application on AOSP

Question
Can I can set a default app on a build if two apps of the same category are
installed?
Example
I am adding a custom browser on AOSP. I want to set it as the default browser before the build starts.
On the Android.mk file for packages there is an option to specify 'LOCAL_OVERRIDES_PACKAGES' which basically overrides the install of the packages mentioned making my app as the default.
But I would want the other app to be a part of the ROM with my app as the default.
Any ideas will be appreciated.
So I found a solution for setting an application as default at build time. I am documenting it in the hope that it helps someone else down the line.
The Android system keeps a list of the default applications/activities in a block in a file located at /data/system/users/{*user-id*}/package-restrictions.xml called as <preferred-activities></preferred-activities>
This file is generated by the Settings.java and the PackageManager.java upon build time. Whenever the defaults on the android system change, the flags on this xml block change accordingly.
At build, the system reads a set of preferred-activities from an additional location which is /system/etc/preferred-activities/*.xml
In order to add our desired preferred/default activities we create an xml file and place it at /system/etc/preferred-activities/ which is then read by the android system and the list of preferred activities are added to the list in package-restrictions.xml
Example
Adding a custom browser to AOSP
If only the default browser is being installed on the device other
that 'mybrowser' the following xml file should be created. In this
case, I am naming it as preferred-activies-home.xml
<?xml version="1.0" encoding="UTF-8"?>
<preferred-activities>
<item name="com.mybrowser.MainActivity" match="200000" always="true" set="2">
<set name="com.mybrowser./.MainActivity" />
<set name="com.android.browser/.BrowserActivity" />
<filter>
<action name="android.intent.action.VIEW" />
<cat name="android.intent.category.DEFAULT" />
<scheme name="http" />
</filter>
</item>
</preferred-activities>
Copy the above xml to the /system/etc/preferred-apps/ location by adding the following line in <!--AOSP_SOURCE-->/build/target/product/full_base.mk
PRODUCT_COPY_FILES +=/<location-of-file>/preferred-activities-home.xml:system/etc/preferred-apps/preferred-activities-home.xml
After build, the browser activity will be set as default
Limitations and Caveats
There are some limitations to the above mentioned process. They are as follows:
Upon build time, we would need to know the main activity for ALL the
applications which are addressing the particular intent-filters.
The above process does not work for Launcher upon the first boot.
The presumption is that the ResolverActivity does not consider the
package-restrictions upon the startup.

Start an Android Wear app with a "Start ..." voice action different from the app's name

I have an app with a difficult name that the system's built-in speech recognizer is not able to properly understand. For this reason, assuming that my app is called X, I would like to be able to launch it by saying "Start Y."
As described in the official documentation, the name of the app is defined in the manifest:
<application
...
android:label="X" > ... </application>
while the text to say after the "Start" command is defined here:
<activity
...
android:label="Y" > ... </activity>
However in doing so the name of the app in the app list becomes Y, while I would like it to remain X...
The only thing you can do is to use an activity alias with a different label. In this case the user will see two icons in the list.

How to set service description that shown in task manager

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

Go to settings screen

I want to open the Settings-> Sound & Display-> Phone Ringtones screen from my application. How can I do that?
Depending on your needs, there are a couple of alternatives to bring up the 'Ringtones' settings screen from your application.
If you want to bring up the actual preferences screen that is usually available through system settings -- letting your user modify the phone's universal ringtone settings through your application -- you can use the ACTION_SOUND_SETTINGS constant from the android.provider.Settings class to create a new Intent to start the sound settings activity.
startActivityForResult(new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS), 0);
If you want to select a custom ringtone to use in your application you need to add a RingtonePreference in your preferences.xml definition file, like this:
<RingtonePreference
android:key="alerts_ringtone"
android:title="Select ringtone"
android:showDefault="true"
android:showSilent="true"
android:ringtoneType=""
/>
You'll be able to get the URI to the selected preference in the application's default SharedPreferences using alerts_ringtone as the key.
The latter technique uses the PreferenceActivity class to host the preference options. I won't describe that in detail here, as the Android documentation has a good writeup and some sample code.
This is an alternate solution for the problem. I am also working in the same task but the above code does not work for me. I have changed the code to
startActivityForResult(new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS), 0);
and it now works.

Categories

Resources