I am working on automating the process of launching the dependencies for an android project.
One of the dependencies is launching Termux (Installed through F-Droid not Play store as recommended).
I am trying to launch the installed Termux application through another application and add some commands to its ~./bashrc file for the sake of automation.
I know that an installed app can be launched trough another android app (more details are here).
I wonder to know if this is possible for Termux as well? I wonder to know if we can use intent concept to launch Termux from an android app as well? If yes what is the Termux package name?
I tried using "com.termux" as its packagename in my sample code, but it did not work.
In other words, the following line returns null:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.termux");
Updated:
I can open another installed app (the app that I developed and installed its apk file on tablet) using Intent concept as shown above (by replacing the appropriate package name instead of termux package name).
Note:
I have installed the Termux through F-Drioid not google play store.
New observation:
I confirmed through Package names application the Termux package name is "com.termux" and its activity class name is also "com.termux.app.termuxActivity"
But seems like the "com.termux" is not accessible through package manager. When i try to pass "com.termux" to the following function it returns false.
Any idea or suggestion?
public boolean isPackageExisted(String targetPackage){
enter code here
PackageManager pm=getPackageManager();
try {
PackageInfo info=pm.getPackageInfo(targetPackage,PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
return true;
}
Add com.termux to queries element or declare QUERY_ALL_PACKAGES permission in AndroidManifest.xml if targetSdkVersion is 30+. Check Package Visibility or this article for more info. Otherwise, you will will get PackageSetting{...... com.termux/......} BLOCKED errors in logcat.
<manifest
<queries>
<package android:name="com.termux" />
</queries>
</manifest>
Moreover, you can run commands in termux via RUN_COMMAND intent. The termux-shared lib is published on jitpack since v0.116, check Termux Libraries for import instructions.
Moreover, activity name is com.termux.app.TermuxActivity.
Related
The PackageManager.getPackageInfo(packageName, flags) method can be used to check whether a specific package has been installed. It either returns the PackageInfo or throws PackageManager.NameNotFoundException.
How to check if a library APK is installed? An example of the library APK is Trichrome Library: https://www.apkmirror.com/apk/google-inc/trichrome-library/trichrome-library-98-0-4758-101-release/trichrome-library-98-0-4758-101-3-android-apk-download/download/
After installation of this APK, calling PackageManager.getPackageInfo('com.google.android.trichromelibrary', 0) throws PackageManager.NameNotFoundException.
Looking via ADB, I see that once installed, it's not visible under pm list packages but it's visible under pm list libraries with the name "library:com.google.android.trichromelibrary".
Is there any way to determine programmatically whether the library has been installed?
As you can see in the source code of pm in this link, pm list libraries command uses PackageManager.getSystemSharedLibraryNames() which is documented here.
If this method is not working, there are also other methods in PackageManager to get info about shared libraries. As mentioned by #vmayorow, One of these methods is PackageManager.getSharedLibraries(0).
I have inherited an Android project without having much idea about the development on this platform. First I want to explain why I want to debug a system app if you have any idea about the problem:
This project is a system app and has to change Settings.Secure.LOCATION_MODE's value. Now the customer has problems with this feature and wants to solve it.
The device is Android 5.1 with manufacturer's special permissions and the APK file is in system/priv-app folder.
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> is in AndroidManifest.xml.
I get this exception: "Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS".
In the main actitvity this condition is checked:
public boolean isSystemApp() {
return (getApplicationInfo().flags & (ApplicationInfo.FLAG_SYSTEM |
ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0;
}
So I want to debug the system app running it in the system/priv-app to have privileges. Is it posible?
I am new to programming generally please I need some help!
My app was installing successfully after every update until i decided to add the 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha' library to the app because i need the user to be able to view some data in form of statistical charts.
The library was synced successfully and have used packages and classes therein successful. But when i try to install the app in my android device it returned this error:
Installation failed with message Failed to commit install session 590492354 with command cmd package
install-commit 590492354. Error: INSTALL_FAILED_MISSING_SHARED_LIBRARY: Package couldn't be installed in
/data/app/com.cenitscitech.www.etimebook-jOP-jv2YuNu7_8qnkfqp-A==: Package com.cenitscitech.www.etimebook requires unavailable shared library com.google.android.things; failing!.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing." I have pasted a screenshot here:
I uninstalled the existing version of the apk, cleared some memory space but keep on getting the same message! What should I do next please?
You are most likely installing on a device that is not an Android Things device. I suspect the library you added either has some transitive dependency on com.google.android.things, or something else changed in your project.
To get around this, you must do the following 2 things:
1. Mark that Android Things is not required on the device in your AndroidManifest.xml file:
<uses-library
android:name="com.google.android.things"
android:required="false"
tools:replace="android:required" />
(tools:replace is not strictly required, but it just there in case something in the manifest merge process overrides your setting.)
2. In your app's code, before making any calls to the Things APIs, make sure that they are available on the current device. This can be tested with the following code snippet:
public boolean isThingsDevice(Context context) {
final PackageManager pm = context.getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
}
Only doing 1 should fix the install problem, but your app will crash if you make any Things API calls on a device that isn't an Android Things device.
Had a look in the com.github.PhilJay:MPAndroidChart:v3.1.0-alpha repository and did not find any reference to com.google.android.things inside the source code.
You need to remove the below entry in case it's found in the AndroidManifest.xml of your app for it to work on your device again:
<uses-library android:name="com.google.android.things" />
I already found AppAvailability plugin which basically checks if a user installed a certain app on his device.
Is there a possibility to the current version of the app, developer name (important) and everything it possibly can? Is this even possible in general?
Using AppAvailability plugin it is not possible to get the current version of the app.
You would have to use Cordova AppVersion plugin instead.
After install (e.g. cordova plugin add cordova-plugin-app-version), you can this JS code:
cordova.getAppVersion.getVersionNumber().then(function (version) {
$('.version').text(version);
});
Here is the list of methods which you can use to retrieve other details about your application:
getAppName
Returns the name of the app. E.g. "My Awesome App"
getPackageName
Returns the package name of the app - the reversed domain name app identifier like com.example.myawesomeapp.
getVersionCode
Returns the build identifier of the app
getVersionNumber
Returns the version number of the app
Related posts:
How to get the application version and build in an iOS PhoneGap Application?
User versionName value of AndroidManifest.xml in code
Command Line
Also, the version can be found via the command line
$ cordova info
Scroll down until you see Project Setting Files:
config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.your.app" version="1.1.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
I am attempting to white label my app by changing my Android Application Project into an Android Library Project and then importing the library into a new Android Application Project.
I am running into a problem with the fact that my app (read: Library Project) contains a ContentProvider.
When I attempt to install my new Android Application Project onto an emulator, console tells me:
[2014-01-24 13:35:39 - WhitelabelTest] Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER
[2014-01-24 13:35:39 - WhitelabelTest] Please check logcat output for more details.
[2014-01-24 13:35:39 - WhitelabelTest] Launch canceled!
According to the logcat:
01-24 13:38:52.217: W/PackageManager(58): Can't install because provider name com.myapp.app.db.providers.MyProvider (in package com.example.whitelabeltest) is already used by com.myapp.app
01-24 13:38:52.227: W/PackageManager(58): Package couldn't be installed in /data/app/com.example.whitelabeltest-2.apk
Does this simply mean you cannot have both applications installed on the same device because they use the same ContentProvider? Or is there a way around this? Do I need to create a new ContentProvider in my new Android Project with a new name instead?
Here is the Provider as listed in my WhitelabelTest project's Manifest:
<provider
android:name="com.myapp.app.db.providers.MessagesProvider"
android:authorities="com.myapp.app.db.providers.MessagesProvider"
android:exported="false" />
I attempted to change the name parameter with the same result.
Does this simply mean you cannot have both applications installed on the same device because they use the same ContentProvider?
You cannot have both applications installed on the same device because they both attempt to declare the same authority (in android:authorities) in a <provider>. There can only be one provider for a given authority.
This is similar to how you cannot have two apps installed with the same package.
Do I need to create a new ContentProvider in my new Android Project with a new name instead?
I'd start by considering whether a ContentProvider is necessary, and perhaps drop it if it is not.
Otherwise, the implementation of the ContentProvider can be the common one from the library project. However, the android:authorities must be unique, and therefore any clients of that ContentProvider need to know the right authority to use to reach the right provider.