Can anyone tell me what "on O+ for instant apps" mean? - android

The following information is from Android Developer's page.
I like to understand What "O+" in the context below. Is it version like Oreo?
updateAppInfo
void updateAppInfo (Context context)
Updates application info based on currently installed splits.
Note #1: This method must be called after split is installed on O+ for instant apps, so that application components can see new resources and code from new splits.
Note #2: This method will update application info reference in application thread object.
Note #3: This method should only be called on O+.
Example usage:
// SplitInstallAPI callbacks
public void onStateUpdate(SplitInstallSessionState splitInstallSessionState) {
if (splitInstallSessionState.status() == SplitInstallSessionStatus.INSTALLED) {
// Use SplitInstallHelper API on O+ to update application info after the splits are
// installed.
if (BuildCompat.isAtLeastO()) {
// Updates app info with new split information making split artifacts available to the
// app on subsequent requests.
SplitInstallHelper.updateAppInfo(context);
}
}
}

Yes. In this case O is short for Oreo. Each major version of Android (from 1.2 onwards) is named after a dessert or other sweet food, and versions are codenamed in alphabetical order starting with C for Cupcake. Versions are often shortened down to their first letter for quick reference, or when the version name has not yet been decided (which is currently the case for Android P).
So in your example, the function BuildCompat.isAtLeastO() checks that the current device is running at least Android Oreo (API level 26).

Instant apps is a mini-application that does not need to be installed. Not all standard methods can work in it.

Related

Delete system cache on android 6.0

I'm using method freeStorageAndNotify() with permission android.permission.CLEAR_APP_CACHE to delete system cache of all installed applications. But the method started throwing InvocationTargetException from the android marshmallow 6.0 version.
After googling the issues I found the same issue as reported here:
Android M reflection method freeStorageAndNotify exception
So here the conclusion was, freeStorageAndNotify() stopped working since google has raised the method's signature level now to signature|system.
But now the question is how other third-party apps like 'Clean master' are still able to delete system cache of all installed applications by taking accessibility permission from the user for 6.0 devices?
I don't think that 'Clean master' actually uses Accessibility Permissions to clean installed apps cache.
But, if you're interested, this goal can be achieved by using AccessibilityService in your application.
Within your class that extends AccessibilityService you have this callback:
#Override
public void onAccessibilityEvent(AccessibilityEvent aEvent) {
AccessibilityNodeInfo rootNode = aEvent.getSource();
//...
}
Here you can invoke
rootNode.findAccessibilityNodeInfosByViewId()
or
rootNode.findAccessibilityNodeInfosByText(),
it will return all matching AccessibilityNodeInfo objects (sub-nodes) in tree. Then, you just need to detect which of them is Button (node.getClassName()) and call subNode.performAction(AccessibilityNodeInfo.ACTION_CLICK).
On Android M, you first need to to open system's App Info screen (you can find instructions here How can I start android application info screen programmatically?) for the concrete app and, by the scheme described above, perform sequential clicks on the buttons "Storage" —> "Clear cache".
In order to clear cache for all installed apps you probably have to iterate through the all installed apps (List<ApplicationInfo> installedApplications = context.getPackageManager.getInstalledApplications(0);)
and repeat the procedure mentioned above.
The system cleaner I'm using has access to the STORAGE permissions. This permission gives the app authority to clear any data in the shared external storage directory.
http://developer.android.com/reference/android/Manifest.permission_group.html#STORAGE
I don't think any 3rd party app can actually clear system cache anymore unless the device is rooted and the app is designed for rooted devices.
those apps only do the same thing all the time. use it on an old device and a new device the results are the same. the only help i have seen is that they can kill or restart some background processes, not to clean the cache. therefore no API can restrict their trick..

Restoring chromecast connection fails: Unselecting the current route because it is no longer selectable

I'm developing an Android app that supports Chromecast.
When trying to reconnect, in the callback:
public void onRouteAdded(final MediaRouter router, final MediaRouter.RouteInfo route)
I check whether the routeId is the one I was connected and in that case I select it calling:
mRouter.selectRoute(newRoute)
What happens is that my onRouteSelected callback is triggered but just after that the onRouteUnselected is called. This does not happen on all the phones.
Tracing what happens I saw that the implementation of selectRoute ends sending a "route unselected" message to an Handler. The passed route is the default one so the one that was selected when I tried to select the new one. The route that I receive in the onRouteUnselected is the new one instead so the one that was just selected.
Has anyone seen this issue?
Edited
In the logs I see "Unselecting the current route because it is no longer selectable"
Following the solution suggested in this issue I installed the new version of the Google Play Services. I'm still using the jdk 1.6. The problem now is that I get onConnectionFailed with ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED.
To fix this issue with the version I had to force gradle to use version 5.0.89 that is the one that is installed on the phone. After having done this the application runs again on the phone but the reconnection still fails
Edited2
Please notice that you need to have a strong reference (mRouter) to a router object in your "ChromecastManager" class and you should use that one to select the route. You should also look in mRouter.getRoutes() for the route with newRoute.getId() == oldRoute.getId(). So you can't call mRouter.selectRoute(route) where route is the object passed to onRouteAdded
It seems it is working now. The only thing I did was to execute the router.selectRoute asynchronously and not in the onRouteAdded. So I execute the selection in an Handler.
So to update the Google Service isn't necessary. In case you update the Google Service as I did you do not need to use JDK 1.7. I don't know why I get the warning
"warning: com/google/android/gms/common/api/PendingResult.class(com/google/android/gms/com‌​mon/api:PendingResult.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded."
even if openjdk-6-jdk is already the newest version.

What is the name of GoogleTTSService in JellyBean 4.3?

In all Android versions prior to 4.3, the name of Google's text-to-speech service, belonging to package android.tts.TtsService, is GoogleTTSService.
Thus, if you inspect the list of running services in devices running Android 4.2 or lower, you will find com.google.android.tts.GoogleTTSService among them.
But in Android 4.3 that seems to have changed and, among the many services listed in my running device, I can no longer find a corresponding service name.
What is the new name?
Is it part of a different service?
Update: It appears that the package name for the service has been renamed from android.tts.TtsService in 2.x to android.speech.tts.TextToSpeech in 4.3. That's a step in the right direction but the actual name of Google's engine is still missing.
Any idea?
You can discover the package for any TTS Engine in the following way:
TextToSpeech tts = new TextToSpeech(context, onInitListener);
Then in the onInit Listener:
#Override
public void onInit(final int status) {
switch (status) {
case TextToSpeech.SUCCESS:
try {
final String initEngine = tts.getDefaultEngine();
// Output the engine to the log if it's != null
} catch (final Exception e) {
}
break;
}
}
From my experience, the engine can sometimes return null or crash when it's called too soon after onInit, so surrounding with a try/catch block is recommended. This was only happening with some IVONA and SVOX TTS engines, but of course the user could have one of those as their default.
According to this, you may be using the ACTION_CHECK_TTS_DATA intent, which is not handled correctly in Android 4.2.
Try to eliminate the use ACTION_CHECK_TTS_DATA intent and instead we just rely on the method TextToSpeech.isLanguageAvailable() as an indicator of whether or not the voice data is installed.
Additional useful information that may be related to your problem:
Access the Google Now voice using the Android TTS APIs
Offline Speech Recognition In Android (JellyBean)

Opening an Android application within another

I am trying to open a different, already installed android application within another, on click of a button. The new application should be opened in a part of the screen within the calling application.
Currently, my code creates a new intent and runs the called application in that. the calling application disappears. Here's my code:
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.ritwik.camera");
startActivity(intent);
}
});
Ideally, it should open as a part of the same screen, without sidelining the parent(calling) application. How do I do that?
When you start an Intent to execute another application (i.e. because you are implementing a launcher or a main menu replacement) you are actually asking android to execute the application identified with a specific package (or the one satisfying some specific constraints, like the ability to handle images, videos, etc), without any clue or reference about the Activities it contains (nor the ability to get any...).
Therefore I don't think that what you are trying to achieve is possible with the current version of the OS (unless some vendor is providing extensions to do just that, see the comment by Pratik).
The new application should be opened in a part of the screen within the calling application.
This is not possible with conventional third-party application UIs.
AFAIK, the split-screen feature (Adaptive UI) is supported from Android 3.0 onwards.
That has nothing to do with embedding the UI of third-party apps into your own.
So I didn't get what you meant to say by "it's not possible with the current version of the OS"
It is not available on any stock version of Android released up through March 26, 2013 at 9:50am Eastern Time.
Certain device manufacturers, like Samsung, have extended Android with multi-window capabilities. However, the control over those windows lies with the user and the (modified) OS. Unless there is something in their S-Pen SDK for this, you have no way of starting another window.
Android also has RemoteViews, which is a means of passing a simplified UI between processes. Using this, it is possible for one app to embed RemoteViews published by another app. You see this with app widgets on the home screen, for example. However, both apps have to be written with this in mind, such as an app publishing an AppWidgetProvider to supply app widgets to home screens.
As far as I know, this is NOT possible. You can only launch the new activity, but you have no control of it.
EDIT: Some devices offer this possibility using Cornerstone or similar frameworks, but I haven't seen an option for developers to use this for their own apps.

Reject Incoming calls in android [duplicate]

I want to block calls from few numbers, for that I want to write a app of my own.
So what are the APIs which I should be using?
Basically I want to get notified when a call comes, i want to compare numbers if it is what i want to block, i want to cut the call or mute it or if possible mute it and record it.
OMG!!! YES, WE CAN DO THAT!!!
I was going to kill myself after severe 24 hours of investigating and discovering... But I've found "fresh" solution!
// "cheat" with Java reflection to gain access to TelephonyManager's
// ITelephony getter
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony)m.invoke(tm);
all all all of hundreds of people who wants to develop their call-control software visit this start point
there is a project. and there are important comments (and credits)
briefly: copy aidl file, add permissions to manifest, copy-paste source for telephony management )))
Some more info for you. AT commands you can send only if you are rooted. Than you can kill system process and send commands but you will need a reboot to allow your phone to receive and send calls =)))
I'm very hapy =) Now my Shake2MuteCall will get an update !
It is possible and you don't need to code it on your own.
Just set the ringer volume to zero and vibration to none if incomingNumber equals an empty string. Thats it ...
Its just done for you with the application Nostalk from Android Market. Just give it a try ...
In android-N, this feature is included in it. check Number-blocking update for android N
Android N now supports number-blocking in the platform and provides a
framework API to let service providers maintain a blocked-number list.
The default SMS app, the default phone app, and provider apps can read
from and write to the blocked-number list. The list is not accessible
to other app.
advantage of are:
Numbers blocked on calls are also blocked on texts
Blocked numbers can persist across resets and devices through the
Backup & Restore feature
Multiple apps can use the same blocked numbers list
For more information, see android.provider.BlockedNumberContract
Update an existing project.
To compile your app against the Android N platform, you need to use the Java 8 Developer Kit (JDK 8), and in order to use some tools with Android Studio 2.1, you need to install the Java 8 Runtime Environment (JRE 8).
Open the build.gradle file for your module and update the values as follows:
android {
compileSdkVersion 'android-N'
buildToolsVersion 24.0.0 rc1
...
defaultConfig {
minSdkVersion 'N'
targetSdkVersion 'N'
...
}
...
}
You could just re-direct specific numbers in your contacts to your voice-mail. That's already supported.
Otherwise I guess the documentation for 'Contacts' would be a good place to start looking.
You can do it by listening to phone call events . You do it by having a BroadcastReceiver to PHONE_STATE and to NEW_OUTGOING_CALL. You find there what is the phone number.
Then when you decide to end the call, this is a bit tricky, because only from Android P it's guaranteed to work. Check here.

Categories

Resources