i search how can i get the IMSI number of android devices.
and i understand that i have to use SystemProperty class as it explained here:
getting IMSI from android phone?
but when i am trying to pass this parameter, TelephonyProperties.PROPERTY_IMSI, to the SystemPropery class it shows me this error:
"cannot be resolved to a variable"
The link you posted has the answer, those properties are not publicly accessible, you can use tricks to get to them but there is no guarantee that they will exist in all/future releases/devices.
https://stackoverflow.com/a/5656732/329034
Related
I have an app that needs to create a file in an app-specific directory, but that file need to be public so it can be edited by another app, so I need a path like this "/storage/emulated/0/Android/data/com.my.app/files"
I already checked Xamarin Documentation and I found what I need. Based on that Documentation I can use this method Android.Content.Context.GetExternalFilesDir(string type).
But I get this error when I call that method.
An object reference is required for the non-static field, method, or property 'Context.GetExternalFilesDir(string)'
I also already check this forum but found no luck
Any ideas how to solve this issue ?
To get privateExternalStorage you can use this
Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;
When I write in my strings.xml "android:strings/" I only get a few strings, is there the possibility to access any string of the Android platform and how?
Bonus questions: is there a site where I can explore all strings, I remember finding such a page in the past but was not able to find something like that anymore, grepcode does not have Android 6 yet to explore.
Most strings on the Android platform are declared private - meaning developers should not be trying to use them. They may not exist, or the IDs may change between different builds of Android.
However, if you know for certain that a particular string will exist on a device, you can reference a private string using the #* prefix:
<TextView android:text="#*android:string/data_usage_warning_body" />
Just don't do this if you expect the App to work across multiple devices and Android versions.
Bonus: androidxref is a good site for exploring the Android source. You can find some resource strings here
You can check out the github repository for Android. It contains all the resources including the string.xml. The following link should bring you to the marshmallow resource folder: Android on Github
I don't know if you can just reference those string directly.
Android crashes are often caused by a resource containing %1$ s when %1$s was intended.
To my surprise, Android Studio does not show these syntax errors:
↑ The real syntax error above is the %1$ s (makes the app crash), not the ellipsis that Android Studio highlights.
How to check for resource variable typos in Android Studio?
I am looking for the equivalent of lint --check StringFormatInvalid.
Context: Many semi-automatic language translation tools break variables, making apps crash.
What I have tried, does not work:
in Intellij it is possible to create custom inspections. I am not sure if it is possible in Android Studio.
Follow the link:
https://www.jetbrains.com/idea/help/creating-custom-inspections.html
edit:
after follow the steps in the link you see in the next image my created inspection:
In the next image you see the basic configuration of the inspection:
In the next two images you see the setting of the variables.
Only the used regex is not the ready. You must write it for general variable using (between $ and . is a space):
Every thing in strings.xml between <string> and </string> is merely a string for Android studio and lint. It will not identify syntax typos. Syntax errors/typos means error with code and not strings. You'll need to make sure that these are written right by yourself or create your own script to do these checks on the string.xml file. There is no inbuilt mechanism to identify code in strings and then check for syntax errors in them.
The highlighted thing with ellipses is there because it is a grammatical (optimization) error. If you make a spelling/grammatical mistake in strings.xml it will be highlighted. Example below:
But, if you intend to put in formats/code as strings it needs to be handled on your own or using some custom script that you'll need to write by yourself. Or as mentioned by #Rüdiger in his comment on the question, you can write unit test cases to check the sanity and integrity of your strings in strings.xml.
I have an Android App written using Xamarin for Visual Studio. When it runs I get the warning:
Failure getting entry for 0x01080acd (t=7 e=2765) (error -75)
I know there is something wrong with one of my resources, but I can't seem to figure out which resource has the ID of 0x01080acd. I tried looking at it while debugging in the activity OnCreate method, but it doesn't seem to work. Any suggestions on how I might track this down?
Jim
If that is truly a resource ID, open the file Resource.Designer.cs in the Resources folder of your project.
Search for 17304269 (decimal for 0x01080acd).
If there's a match, that'll be the ID.
Otherwise, it might be a global resource or some other value.
If there is a problem with a resource then check the naming, resources must not start with number and use only letters and _ and also not any capital latter.
Check also here for naming rules http://developer.android.com/guide/topics/resources/providing-resources.html#QualifierRules maybe you have made an icon for some resolutions and forget to make it for others,
like in this similar question android failure getting some entry
My android application has several warnings of the following form when I run it in the emulator:
"Resources don't contain package for resource number <Hex Address>"
How can I fix these warnings? In particular, is there an easy way to find out what the hex address refers to?
These appear to be coming from the emulator, but it is now working fine, so these aren't errors. Still curious why they are occuring though
Just a guess, but isn't the hex address from R.java?
If so, you should be able to identify the resource pretty easily.