Launch a system generated application with same package name - android

I am trying to make a small application that can launch an application, not usually shown in the app drawer. This application is generated by the system and is carrier specific. It belongs to the package com.android.stk - for those of you who don`t know it is the SIM Toolkit application. The SIM Toolkit application itself can not be launched, but when I insert my sim card, it creates a carrier specific application - In my case: Dialog Services, which can be run to make changes to sim settings.
The problem is that the package name for the Dialog Services app is still com.andorid.stk . All I want to do is open up that app. Is there any way to do this... Possibly search for all apps within com.android.stk and selecting or launching that one...
I am relatively new to Android dev, so All help is appreciated.

You can launch any installed application whose package name is known:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.andorid.stk");
startActivity( LaunchIntent );

Related

Integrating Multi Projects into single app

I have three existing apps. Now i want to combine all the three into single app.
Say i have three button, when i click button 1 then app 1 should run. And when
button 2 is clicked app 2 should run. Is it possible in android studio? have
have tried searching but nothing helped.
From this SO start application knowing package name. Just use these two lines you can launch any installed application whose package name is known:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.example.abc");
startActivity( LaunchIntent );
for the unknown package name
PackageManager pm;
pm = getPackageManager();
// get a list of installed apps.
packages = pm.getInstalledApplications(0);
I'm going to preface this by saying I do not have any experience with Android Studio. Hopefully it bears some resemblance with its terribly simplified counterpart App Inventor.
Anywho, I would create an independent main screen (activity?) that has 3 buttons on it and paste the three existing apps' code into other screens in the same app. Each button would open its corresponding screen/app through opening a new activity.
Got the solution. I just converted the three applications to library and imported them into the main app. Now i can call any activity from any of the three app any time as required. While using package manage all the three apps would have to be installed separately. Thank you coder and himty for sparing some time to answer my question. But still i have a problem. I am actually working on watch faces. Even though i can launch any activity, i still can't change the watch face. Tried Wallpaper but we can only open the face picker & cannot set the watch face.
ComponentName unique=new ComponentName(MainActivity.this,BlackOwlBlue.class);
Intent i=new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,unique)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

Automation on Android Device

I am looking for a way to automatically open an application on Android. Something like QTP on windows. I read about quite a few testing tools for Android that need the phone to be connected to the laptop via USB. Is it possible to code an android application that can open another specific application on the device automatically?
I understand that if it is my application or an open source one, I can get the UI element and perform click or type into it automatically using code but how can I access UI elements of other apps on the device.
Example: My app should be able to open my phone keypad and type in a number or open an app like Truecaller and type into the textview on main screen? Something like web automation but for Android device. Any help would be appreciated! Thank you!
You can use Intents:
//consider context as being the Context of your current app
PackageManager packageManager = context.getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(PACKAGE_NAME);
context.startActivity(intent);
device.wait(Until.hasObject(By.pkg(PACKAGE_NAME)), 10000); //this is a UiAutomator method to wait for the application to be started (or 10 seconds).
You can also use solo UiAutomator methods: open the apps menu, click on the app icon. You can see an example here

Get only applications with launchers through adb

I have to get the package name of all the applications installed on the phone which has a launcher i.e. which appears in the app list of the phone.
I know pm list packages lists down all the package but it also includes the services and system applications. I want only the apps which show up on the app menu of the phone.
Also I don't want to use monkey runner, any other alternative would be great.
Any help?
Try calling getLaunchIntentForPackage() in PackageManager on each package installed. If it returns null, then it has no launcher. Although you may get a few false positives from apps with a MAIN activity but without a launcher.

Is it possible to get Intent from running Activity from another application?

I will prevent some application to be deleted from the phone.
Now, I can get current top activity name using ActityManager and check if it is com.android.packageinstaller.UninstallerActivity, than do additional logic for checking which package will be deleted. but I can't get UninstallerActivity object, and more - I can't get Intent passed to com.android.packageinstaller.UninstallerActivity (which will provide package name for me).
Seems like this isn't possible with standart Android API way. maybe it's possible using hidden API and reflection.
Any ideas?
Edit: I'm writing Launcher application, which will be distributed manually in hotels. I will have functionality which prevents from deleting my Launcher application from the phone, because mobile phones will be given in rent, and Launcher replacement isn't possible.
Note: The phone will be rooted!

Android - Access class in phone.apk

Hi guys this is just my first post,
is it possible to access an activity which is in Phone.apk in a non-rooted phone?
I've tried something like this
Intent i = new Intent(Intent.ACTION_MAIN);
i.setClassName("com.android.phone", "com.android.phone.PhoneApp");
startActivity(i);
but my app always stops unexpectedly.
There is no activity named com.android.phone.PhoneApp in the Android firmware, let alone in the Android SDK.
Moreover, you should not be attempting to start activities in the com.android package, as they are not part of the Android SDK and may or may not exist on any given device or Android version.

Categories

Resources