[Q] KitKat 4.4 SMS Default Change Detection - Java for Android App Development

Anyone know if you detect when another app becomes the default SMS app within Android 4.4 (KitKat)? The only solution I have figured out, would be to check if my app is the default SMS app as often as possible (i.e. app load, user actions, etc). It would be interesting to have a custom service running that is listening for a change event (if one exists) for the SMS default app change.
For more background on the KitKat 4.4 SMS changes, read the official Android blog:
android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html
Android handles the presentation of the activity which appears when the following code fires:
Code:
Intent i = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
i.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, myPackageName);
startActivity(intent);
If you have KitKat running on your device, you can install the simple test app I created, which demonstrates changing the default SMS app on Android 4.4
play.google.com/store/apps/details?id=com.mysquibs.kitkatsmstester

Related

[Q] Android app auto starts again when device rotated

Hello all,
I've written a simple audio player app and testing it in Samsung Galaxy S.
It is a simple app with can create playlist and some buttons to play the mp3 file.
However, there's a funny bug in it.
After starting the app, whenever I rotate the phone, the running app will launch another instance of the app. If I rotate again, another instance (3rd) would be started. So u can hear 3 copies of the same audio being played simultaneously.
What could be wrong with it?
Is there some code which can prevent program re-entry?
Thanks.
It's not a bug, that's the way andorid OS works. You need to account for this in OnCreate for your activity. I assume you are spawning off the actual playing of the MP3 in a thread or service. You need to check if the service is already running in OnCreate and attach, else spawn a new one.
Hello Gene,
How do I check if an activity is already running?
I could not find the answer on the android developer page (the topic on application fundamentals).
And no, I'm not converting it to a service yet as this is my first app.
Haven't explore service yet.
Thanks.
I read on another article, a simple way to prevent this is to add overwrite the onConfigurationChanged function
@Override
public void onConfigurationChanged(Configuration newConfig) {
//ignore orientation change
super.onConfigurationChanged(newConfig);
}
and modify the androidmanifest.xml
<activity android:name="selectCategories" android:configChanges="orientation|keyboardHidden"></activity>
But it still launch multiple instance of the app.
Thanks.
This is a good question and should be in an FAQ somewhere.
As already mentioned, changing the display orientation basically restarts your app. Read the Android dev page on Activity lifecycle for more info.
A short answer for your question is: the Bundle parameter for onCreate() will be null when your app is first run. When your app is paused and restarted, that Bundle will be non-null. You can store data in that Bundle by overriding onSaveInstanceState(), then check for that data in onCreate(). It's a good idea to learn how to do this (save/read app data on pause/restart). Once you start testing apps by rotating the display at various times, you'll find a lot of them FC at unexpected places.
This is indeed a topic that keeps surprising people who are new to android (ahem, like me 4-5 months ago ).
The solutions above are perfect, however in certain situations there's another trick that might make your life much easier. I suspect it won't help you in this case, but it might help others who tackle the problem and see this thread.
Certain applications, mainly games, should be fixed in a single orientation. I.E. you won't be playing angry birds on portrait - that game is locked to landscape, as it should be. In order to lock your activity in a certain orientation you add this attribute to the manifest under the Activity tag. So a standard activity might look something like that, combined with the ignore tag from the previous posts:
Code:
<activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
android:name="whatever">
The great thing about this combination is that your activity will not restart at all when the phone is rotated. Of course, for a standard activity you'd usually want to support both landscape and portrait, but if you need your app to be in a fixed orientation this is the way to go - no weird FCs or annoying bugs
Hi,
How do I check the bundle?
And also, what to do if the bundle is not null? Just return?
Thanks.
regards
r_p_ang said:
This is a good question and should be in an FAQ somewhere.
As already mentioned, changing the display orientation basically restarts your app. Read the Android dev page on Activity lifecycle for more info.
A short answer for your question is: the Bundle parameter for onCreate() will be null when your app is first run. When your app is paused and restarted, that Bundle will be non-null. You can store data in that Bundle by overriding onSaveInstanceState(), then check for that data in onCreate(). It's a good idea to learn how to do this (save/read app data on pause/restart). Once you start testing apps by rotating the display at various times, you'll find a lot of them FC at unexpected places.
Click to expand...
Click to collapse

[Q] Updating search queries sent to other applications via Intents

I am currently developing an android app that must launch other applications (YouTube, etc) to perform search queries. I have succeeded in sending search queries to other applications via the following code:
Code:
searchIntent = new Intent(Intent.ACTION_SEARCH);
searchIntent.putExtra("query", searchPhrase);
searchIntent.setPackage(packageName); //Youtube package name, etc
startActivity(searchIntent);
Unfortunately, when the queried app is left running and another query is performed, it simply relaunches with the original query, failing to perform another search.
For example: I launch a search intent for YouTube with the name "puppies." I then background that instance of YouTube and launch another search intent with the name "kittens." Upon launching that second intent, the same instance of YouTube launches and continues to show "puppies" in the search bar.
I have tried using various flags (FLAG_ACTIVITY_NEW TASK, FLAG_ACTIVITY_CLEAR_TOP, and others) to no avail to solve this problem.
Does anyone know how I may go about resetting the search query in the launched activity so that a second search can be performed without having to kill the activity instance (back button or otherwise)?
Thanks in advance for your assistance!
Bump. Hopefully someone can provide some guidance!
Even at this point, a solution would still be appreciated!

[Q] [REQ] App Ops (permission manager) from 4.3?

Hi,
I read about the new App Ops (hidden) feature in the stock 4.3 that Google recently released to their Nexus devices. With the S4 that we have, I suspect it will be a while before we get 4.3 from Samsung/Sprint.
http://www.androidpolice.com/2013/0...ager-control-permissions-for-individual-apps/
App Ops basically lets you selectively disable some permissions for your apps.
I know that XPrivacy does something very similar - maybe even better because instead of just denying that permission (that may cause the app to fail), it feeds dummy data (like dummy GPS coordinates, or empty contact list etc). Unfortunately for me, the XPosed Framework that is required to make XPrivacy work causes one particular app on my device (Q-see) to misbehave (screen doesn't render correctly), and I really need that to work.
Yes, I realize that it is probably a bug in the Q-see app, but I can't seem to get Q-see to fix it. (I did contribute to the XPrivacy developer regardless because it was a very impressive app)
Anyway, back to my request
Can a developer take a look at the 4.3 code and see if there is a way to extract the code for the App Ops functionality and build an apk (or a flashable mod) that will work on the stock rooted Sprint S4? (I really like some of the features that the stock ROM offers - else, I would have tried CM and used their privacy guard options instead)

How to know what app is foreground and do something when it goes background

So, I'm developing an application for Android which will only be used in my own couple tablets which are going to public use.
I need an application which keeps track which (possibly 3rd party)application is foreground, and when that application goes to background the service starts activity which will go foreground and show something to the user(for example like some ad, or some review window which asks for start rating).
In Android 5.0 access to logcat is restricted so it needs to be done trough accesibility services I guess? Or is there way to use custom ROM with access to logcat? Or could rooting open it?
Thank you.
As for logcat, root allows access to it
You can get running apps using this piece of code
Code:
ActivityManager am = (ActivityManager) mContext .getSystemService(Activity.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity .getPackageName();
and use an if conditition and a thread to keep checking, at the moment its not meeting the condition the desired code will be triggered

Marshmallow OTA Rolls Out to Verizon-branded N6's

I received build MRA58R today via official OTA. Device is unmolested (bootloader never unlocked). It was 702 MB and everything went very smoothly. The device is really snappy--I'm a happy big red customer!
Nice explanation of Marshmallow new features:
http://www.verizonwireless.com/support/google-nexus-6-update/
Here's the text from the link posted above.
Google Nexus 6 Software Update
[Updates]
Verizon Wireless is pleased to announce a software update for your device. This software update has been tested to help optimize device performance, resolve known issues and apply the latest security patches.
Before you download:
Connect your device to a Wi-Fi network, or make sure it has a strong Verizon Wireless network connection.
Ensure your battery is fully charged before starting the software update.
Current Software Update Benefits
Software Version: MRA58R
Verizon Wireless is pleased to announce a new software update for your Nexus 6. Android™ 6.0 Marshmallow improves your mobile experience with new battery-smart features and enhanced app permissions that give you even more control.
Now On Tap: spot-on answers, fast
Now on Tap, a new feature powered by Google™, helps you stay on task by instantly pulling up relevant information, like driving directions and restaurant reservations, letting you get more done.
A battery that works smarter, not harder
Android Marshmallow's new battery features help your device retain its charge longer.
Doze: When your device is at rest, Doze automatically puts it into a sleep state, but will still allow all your alarms, notifications and calls to ring through.
App Standby: Your seldom-used apps will go into App Standby in order to conserve battery power for the apps you use more often. If an app hasn't been used for several days, its power consumption is reduced to zero. Apps will come out of App Standby immediately once you interact with them.
New app permissions
You now have specific control over what info you share - no more all-or-nothing access. Android Marshmallow lets you define what you want to share and when.
Simplified app permissions
Permission requested only when relevant
User controls to turn on/off any permission, at any time
Link apps without a prompt
Android has always let apps register themselves to handle web URL links. With the new app links feature, the transitions between apps are even more seamless. The platform can determine the default app to use for a particular web link and skip prompting users to select an app.
For example, clicking a LinkedIn connection request in an email could automatically launch the installed LinkedIn app to complete the action, instead of showing the user a disambiguation dialog or launching a web browser.
Direct Share
The Direct Share feature lets users share content directly to targets, such as contacts, within other apps. Previously when sharing content via the Share menu, the user would have to go through a two-step process. First, choose the destination app and then choose the target, such as particular contacts, within the destination app. But apps can now define direct share targets that launch a specific activity that is directly exposed to the user via the Share menu.
For example, the direct share target might launch an activity in another social network app, which lets the user share content directly to a specific friend or community in that app.
Text selection & text editing
Selecting text is easier in Android Marshmallow, with word-by-word forward selection and character-by-character backward selection for increased precision.
After you select the text, actions such as Copy, Share, and Search are shown in a floating toolbar above the selection. When you use an external keyboard to edit, you can use Ctrl-z and Shift-Ctrl-z to undo and redo changes.
Easier device migration with Auto backup for apps
When apps are installed on a new device or an existing device that's been factory reset, they automatically retain previously associated user data. Account information, settings, game scores, and even the layout of the launcher are restored. Default app settings, sync settings, and keyboards are also automatically backed up and restored on new devices.
Simple notifications and volume control
Android Marshmallow adds a Do Not Disturb feature (formerly Priority) with improvements to the design, including:
None/Priority/All are now activated with simple on/off switch.
Clearer options such as Total Silence, Alarms only and Priority.
More precise control of Priority modes, such as for repeat callers, and also by notification category, and starred contacts.
Additional rules flexibility, including those based upon events or with a custom duration.
Each sound stream can now be individually controlled.
Peeking Notification (formerly Heads-up Notification)
Has smoother animations and the ability to configure the behavior of each app.
Next steps and additional links:
Please allow additional time for the apps on your device to continue to download after the software update.
Operating System FAQs
Previous Software Update Benefits
Related
View Software Version - Nexus 6
[Device-Specific Instructions]
How to Use Guide: Verizon Cloud
[How to Use Guide]
Get step-by-step instructions for how to sign up for and manage Verizon Cloud online. Learn how to upload contacts, pictures, videos, music, documents and more.
Advanced Devices - Software Updates
Click to expand...
Click to collapse
Mine is waiting for a WiFi connection before downloading. Verizon customer here..
If I don't see it by the weekend, I'll flash it.
Which baseband version is this OTA? Just curious if it's the same 27R.
bond32 said:
Which baseband version is this OTA? Just curious if it's the same 27R.
Click to expand...
Click to collapse
Good question, thats what i wanted to know also, i assume the base is the same as everyone is using in their roms, or the roms might even have a newer marshmallow base
bond32 said:
Which baseband version is this OTA? Just curious if it's the same 27R.
Click to expand...
Click to collapse
Confirmed mine is 27R.
Ditto... 27R here, as well.
Can anyone let me know if they now are able to use the voicemail icon in the dialer after this update? I dont have this on pure nexus, but a friend with a nexus 6 that just took the OTA says it appears now
The voicemail icon in the dialer (it's actually in "recents") says my VM box is empty. The Verizon visual VM correctly shows what's in my inbox. All messages predate installation of Marshmallow (MRA58R). I'll test to see what a new message does and advise.
Result: VM in recents still shows empty. Verizon visual VM apparently overrides it (IOW, they don't both work). Does the VM in recents work OK on Verizon for non-Verizon Nexus 6's?

Categories

Resources