Comments (3)
Start app, can be done with the Share ANE:
https://docs.airnativeextensions.com/docs/share/launch-applications
Restarting an app and stopping an app however aren't implemented anywhere.
Do you have the code you have used previously? I believe this will be even more restricted with Android 30, they have limited a lot of package control outside your own app now.
from ane-packagemanager.
Hi Michael,
we did all a maybe very dirty way - but it worked and it's still working so far...
The reason for this was, that we was doing some development with MOVERIO glasses from EPSON. We created some "helper apps" outside our main app. To control these helpers - we used our ANE.
to stop:
we pass the argument "updateFilee"
public class UpdaterStopApp implements FREFunction {
public static final String NAME = "UpdaterStopApp";
@Override
public FREObject call(FREContext context, FREObject[] passedArgs) {
FREObject result = null;
UpdaterCtx updater = (UpdaterCtx) context;
try {
FREObject fro = passedArgs[0];
String updateFile= fro.getAsString();
ActivityManager manager = (ActivityManager) updater.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> activityes = ((ActivityManager) manager).getRunningAppProcesses();
for (int i = 0; i < activityes.size(); i++){
if (!activityes.get(i).processName.equals(updateFile)){
android.os.Process.killProcess(activityes.get(i).pid);
}
}
return FREObject.newObject(true);
}
catch (Exception e) {
// done
}
return result;
}
}
to start we used this:
public class UpdaterCallApp implements FREFunction {
public static final String NAME = "UpdaterCallApp";
@Override
public FREObject call(FREContext context, FREObject[] passedArgs)
{
FREObject result = null;
UpdaterCtx updater = (UpdaterCtx) context;
try
{
FREObject fro = passedArgs[0];
String updateFile= fro.getAsString();
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
List<ResolveInfo> resolveInfoList = updater.getActivity().getPackageManager().queryIntentActivities(intent, 0);
for(ResolveInfo info : resolveInfoList){
if(info.activityInfo.packageName.equalsIgnoreCase(updateFile))
{
launchComponent(info.activityInfo.packageName, info.activityInfo.name,updater);
result = FREObject.newObject(true);
}
}
result = FREObject.newObject(false);
} catch (Exception e) {
// done
}
return result;
}
and for restart - just a combination:
public class UpdaterRestart implements FREFunction {
public static final String NAME = "UpdaterRestart";
@Override
public FREObject call(FREContext context, FREObject[] passedArgs) {
FREObject result = null;
UpdaterCtx updater = (UpdaterCtx) context;
try {
FREObject fro = passedArgs[0];
String updateFile= fro.getAsString();
ActivityManager manager = (ActivityManager) updater.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> activityes = ((ActivityManager) manager).getRunningAppProcesses();
for (int i = 0; i < activityes.size(); i++){
if (!activityes.get(i).processName.equals(updateFile)){
android.os.Process.killProcess(activityes.get(i).pid);
}
}
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
List<ResolveInfo> resolveInfoList = updater.getActivity().getPackageManager().queryIntentActivities(intent, 0);
for(ResolveInfo info : resolveInfoList){
if(info.activityInfo.packageName.equalsIgnoreCase(updateFile))
{
launchComponent(info.activityInfo.packageName, info.activityInfo.name,updater);
result = FREObject.newObject(true);
}
}
result = FREObject.newObject(true);
}
catch (Exception e) {
// done
}
return result;
}
private void launchComponent(String packageName, String name,UpdaterCtx updater)
{
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.setComponent(new ComponentName(packageName, name));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
updater.getActivity().startActivity(intent);
}
from ane-packagemanager.
Okay, thanks will investigate. Definitely have a feeling some of this won't work in Android 30, but will see what we can do.
from ane-packagemanager.
Related Issues (12)
- PackageManager Android 64bit support HOT 1
- PackageManager.service.validateSignature(signature) HOT 2
- APP - different ANDROID versions, different behavior HOT 4
- Error: uses-sdk:minSdkVersion 21 cannot be smaller than version 23 HOT 3
- Issue when trying to install an apk on older devices HOT 10
- AndroidX migration
- getUserApps get list of installed user apps HOT 4
- What is the minimum Android version supported? HOT 4
- Main app shutdown when I check install from unknown source in app settings HOT 7
- Error # Need to declare android.permission.REQUEST_INSTALL_PACKAGES to call this api HOT 4
- Can I check if my app has been installed from the Play Store? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ane-packagemanager.