How can I change a phone's language using Kotlin? - java

How can I change the language of a phone using Kotlin?
This is a picture showing the thing that I want to change through the code. Can it be done through the code or not?

It's impossible to do it programmatically. The best you can do is to open Locale Settings screen like this:
startActivityForResult(new Intent(Settings.ACTION_LOCALE_SETTINGS), 0);

Related

How to display google form for muting native ad?

I followed this guide https://developers.google.com/admob/android/native/mute-this-ad
I used this code from github googlesamples too mute a Native Ad.
https://github.com/googlesamples/android-ads/blob/master/advanced/APIDemo/app/src/main/java/com/google/android/gms/example/apidemo/AdMobCustomMuteThisAdFragment.java
But how can i get the same dialog as in the first image? Now i'm getting a simple dialog with the reasons.
This is what i want
This is what i have now after following the guide and using code from googlesamples
The GoogleSamples provides only the way to implement the Mute Ad option. Not the UI.
From their example, you only received default short labels (as "Inappropriate", "Repetitive"...) and use android.R.layout.simple_list_item_1 which is the default list item with only a TextView widget. As the first picture, in production they should use custom strings with their own user interface. According to the documentation you linked:
The implementation of the custom mute interface is entirely up to you. You can place a small close button on the ad, or you can provide some other interface for the user to opt to mute the ad.
The solution might be to map the reasons with your own labels in MuteThisAdReasonWrapper into toString(), and use a custom list item instead of simple_list_item_1.
Did you set it to setRequestCustomMuteThisAd(false) and then check nativeAd.isCustomMuteThisAdEnabled() whether its getting set , So that you can confirm that its not enabled.
Moreover check once, If you are building the adloader after you set it to false .
adLoader = new AdLoader.Builder(context, "ad unit ID").withNativeAdOptions(new NativeAdOptions.Builder()
.setRequestCustomMuteThisAd(true)
.build()).build();
adLoader.loadAd(new AdRequest.Builder().build());

How do I fill text in android from an object?

I am attempting to populate textview with information from objects. I am new to android development and I do not know how to approach this. Hard Coding this in the xml will not work because eventually I would like to open up the same activity but with different information.
I do not know if this is enough information but thank you for responding and if code is needed I would be more than willing to upload code or screen shots.
textview.setText(user.getName());
Refer this
https://developer.android.com/reference/android/widget/TextView.html#setText(java.lang.CharSequence)

Enable Picture in Picture mode programmatically

I'm making a settings activity in my Android video playback app and I want to know if it was possible to enable/disable PIP(Picture-in-Picture) mode programmatically.
To clarify I am fully aware that this setting can be change via application advanced settings or via special app access, but I want to leave that as a last resort. (If there are no other alternatives).
Further more this Activity is isolated from the video threading page itself.(Meaning the user would have to stop the video entirely before coming to this page).
Main reasons I want this is an extra reminder that this app supports this feature and also if the user forgets where to reactivate this function.
Think of it as: Adding another layer of user friendliness
Here is a way to check the setting:
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
return (AppOpsManager.MODE_ALLOWED == appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
context.getApplicationInfo().uid, context.getPackageName()));
I haven't tried setting it programmatically, but this could be a starting point for you.

Display balloon tip in Android activity

I'm curious to implement a balloon tip to show info of different UI elements in an activity. How can I achieve this? On some little effort put to this (correct me if I'm wrong please) using something like canvas rectF???
It sounds like you're looking to create tooltip text. This isn't built-in to the View classes in android, so you'll have to create them or use a library like GreenDroid. This has already been addressed, see the following:
android how to make Tooltip for TextView
Android "Tooltip"

How to make selected pins on top which are overlapped in the MapView in Java, in Android phone

I got a problem in Android application, I don't know how to make the selected pins on top of overlaaped pins.
In objective-c, iPhone we use the below methods But, I don't know how it can be implemented in Android phone, java.
[annotationView.superview bringSubviewToFront:annotationView];
[annotationView.superview sendSubviewToBack:annotationView];
Please suggest any solution,
Thank you,
Madan Mohan
You want a statelist drawable. http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

Categories