how to get an uid from application's own pamameter? - android

I would like to know an uid from application's own pamameter.
I know how to get an uid from PackageManager with package name, however I have noticed that an application can send a fake package name or context which is created with fake package name. How can I create an API to determine exactly an uid from any app's own parameter? Or how to check this app is system app?

Sounds like you want to get the current app id. This should do the trick. Get the result of http://developer.android.com/reference/android/os/Process.html#myUid() and give it to http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackagesForUid(int)

Related

how to set a package name without Website?

I've recently started creating an app for Android. but i do not have a Website.
how to get Package name. Can i make it com.example.(app name) ?
and how to know if it is available or not ?
package name have no concern with any website. It is used to identify your application uniquely in your mobile phone and in any App store. You can set any name or string in your package name i.e com.example.myfirstapplication
it is not necessary that there should be com.example in the package name you can change them also i.e my.first.application.packagename
You can set whatever package name you like, as long as it isnt already taken when you publish it on the playstore.
More good reading: https://stackoverflow.com/a/6273935/5644761

Getting wrong PackageName from context and I cannot touch that code

I am new in Android and I was getting a different "PackageName" from:
context.getPackageName() --> (return the application id?)
instead of using getClass().getPackage().toString()
But I cannot change that part of the code.
So my workaround was to change the applicationId from build.gradle, and package in manifest.
The context.getPackageName() method is used to identify the application using the application id, like com.whatsapp or com.facebook.orca it may be used during interprocess communication.
If you want to identify the package that your class is located you should use getClass().getPackage().toString().
Notice that the application id may not be the same as the package name of your class.
I also recommend that you DON'T change the application id on the manifest if the app is already on the Playstore, since it is an unique indentifier and it will probably don't let you update the app with a different id

Sony SmartWatch - how to get host app package name

I would like to update the SmartWatch widget whenever the user changes the widget settings.
I know it can be done by sending an WIDGET_IMAGE_UPDATE_INTEN intent, but it seems that I don't have the information of host app package name (i.e. com.sonyericsson.extras.smartwatch).
How can I get "host app package name"?
PS: Currently, I've hardwired the "com.sonyericsson.extras.smartwatch" name in my code.
Every time your widget extension is receiving an intent from the host application, the package name of the host app is included as an extra in the intent.
String hostAppPackageName = intent.getStringExtra(Widget.Intents.EXTRA_AHA_PACKAGE_NAME);
You could store the package name for later use in your code. This is also how it is done in the utility classes of the SDK, i.e. it is stored as a global variable in the abstract class ExtensionService, which is used by all Sample extensions in the SDK.
Take a look at the SDK utility classes here

In MIT App inventor Application how to get the device id

Is there any way to get device Id using MIT App inventor?
I am using Activity starter from other stuff and setting properties like this:
Action: android.intent.action.ACTION_MAIN
Activity Class: TelephonyManager
Activity Package: android.telephony
Is this the correct process for getting the device id?
as Gary already mentioned, this is currently not possible with AI
EDIT: However, you can identify a user with OAuth, see an example here http://puravidaapps.com/taifunOA.php. The user can authorize the app to get his email address for identification.
UPDATE: now with the new Extension feature, you can use an extension to get this information, see also my answer here.

Package and Activity name

Good day. I'm working on an android program which is application manager. I want to call the application of "Dictionary.com" but in my code, I should include the package and activity name of this application. Can someone post here the Package name and Activity name of this Application? Please. THANK YOU!!!
Application name is something that visible to the user. So put some user friendly name such as "Digital PocketDictionary"
Package name should be unique. It is recommended if you can use your domain in reverse version. As an example, if you have your own hosting or a website related to this app such as www.digitaldic.com you can use com.digital.dictionary as the package name. Make sure all the letters are simple.
It's a little difficult to get what you are asking for, specially the activity name. But here's what you could do to get the package name.
Install the required apps on your phone and then connect it to your computer and in your Eclipse, go to the "DDMS" perspective. In the devices window, click on your phone's entry. On the right, go to the File Explorer.
Go to system/app. You should see the name of the .apk file. You'll get the name of the package in the "info" column.
Getting the name of the activity might be difficult. you could contact Dictionary.com to get the info, coz I doubt you will be able to start the activity, if Dictionary.com doesn't allow it.
I just tried this code and it works without having to include the activity's name:
PackageManager pm = this.getPackageManager();
Intent i = pm.getLaunchIntentForPackage("com.example.test3");
if (!i.equals(null)){
startActivity(i);
}else{
System.out.println("too bad (-*-)");
}

Categories

Resources