Error in using string resources in IntentService - android

I am trying to get string resource value from IntentService as follows :
String errorTitle = getResources().getString(R.string.no_Internet_connection_error_title);
But it shows an error no_Internet_connection_error_title cannot be resolved or is not a field.
When I type R.string., eclipse shows a list of android defined strings, not defined by me.
I use string resource in activity, but not able to use in IntentService.

I thought one of the guys who commented will post an answer. But as they have not I am posting it.
The solution was either to import R.java file using package name :
import com.android.myApp.R;
Or to use whole package name to get string :
getResources().getString(com.android.myApp.R.string.no_Internet_connection_error_title);

Related

The named parameter 'inputDetailsFromUser' isn't defined. Try correcting the name to an existing named parameter's name

I'm making an flutter app in visual studio code and it shows these errors problems description
and this is the code for one of these problems :
code of the problem
Well, it seems that your PayoutMethod class constructor does not have property named inputDetailsFromUser. Show us the definition of the PayoutMethod class and then we will be able to help you more.

Custom Android lint rule that takes input from outside

I need to write a rule to find if a specific String is found in the comment. I'm referencing to this class to do the comment check, but in this class they only check for a predefined String (STOPSHIP). Now is there any way that the Detector class can refer to a value outside of it? Either a file contains a String or a config file that belongs to an Android project would be great.

Sipdroid - Cannot change package name

I modify sipdroid for my voip app in android. Everything is ok but when i change package name "org.sipdroid.sipua", i cannot register for any server (rollback to name org.sipdroid.sipua and it work fine). Awww What wrong with this name???
i faced this situation and I have a solution which as follows
In this package name "org.sipdroid.sipua" right click on and select refactor =>Rename. And then go to manifest and edit this package name "org.sipdroid.sipua" as "XXX.YYYYY.ZZZ". Then the package name as changed as your wish. and one thing is it will affect all your other packages. you need to change based on your changed package name.
IT IS VERY SIMPLE,please change the package name in Settings.java. YES, that's it. I am success.
private final String sharedPrefsPath = "/data/data/org.sipdroid.sipua/shared_prefs/";
change to:
private final String sharedPrefsPath = "/data/data/org.yourpackage.sipua/shared_prefs/";
It has something to do with Preference Activity used in storing the settings. If you see the files which use Preference you will have to update them with the new package name.
well i did solve the problem of changing package name of sipdroid . and i am at success..
what you have to is . Change your package name in manifest file. and all other packages in src . with same as your package name in manifest file . after that also change path of shared prefs in settings.java file . after that you need also change the package name in sipdroid.xml and at last go to prefrences.xml there is also a reference given in this file for target package change it too .. after changing all packages there comes a time for jni file . the package which names like org.sipdroid.net.impl change it too it will effect osnetworksystem.cpp file change package names on methods with underscore . now everything will fix up . clean the project and run . it will connect to servers as well as package name also changed . cheers :-)

Problems accessing my strings.xml items… i got numbers and not the string value

i found this problem some time ago, but i solve it using this: getString(), or this: getResources().getString()
but now, for this case, it doesn't works, i think it's because i need to get the string values on a NON ANDROID ACTIVITY CLASS. I need the resource values on a remote connection class, that doesn't extends any kind of activity or service.
how i can acces to the variables from my strings.xml on this normal class?
this is the code where i get the error (it gets an integer, and not the string value)
String a =R.string.totalpermission;
Take a look at these two answers (are the same XD):
How to obtain AssetManager without reference to Context?
How can I get a resource content from a static context?
Just an advice: try to read some basic concepts... it seems you don't understand what the R class is and how to use it. Trust me, you waste less time studying than trying to figure out how things work.
I'll add something to existing answers since I found it very useful.
To get your strings you have to use a Context. Your activity will work just great.
String string = getString(R.string.myString);
But if you have something more complex... for exemple
R.string.result -> "You %1$s %2$d cats"
String result = getString(R.string.result, killed ? "killed": "saved", count);
That would give you a result like that:
You saved 10 cats or You killed 2 cats... and so on. You can pass parameters and positional arguments in strings will get replaced by your arguments in getString.
All Android resources are referenced via a resource ID, like R.string.totalpermission. You can see those numbers in R.java (although there's no reason to ever do that).
In cases of strings, you can easily get those using Context.getString. Bonus: You can even pass optional arguments and add dynamic strings that way. You always have a context - how are you getting called? If you really don't have a context, you can create one for the package your resources are in.

Cannot get resource from android application

I am building an Android app, and I have a problem to get resource from string.xml.
I need to have a URL in String.xml that will be used several times through the app.
I tried Resources.getText("my_url"), but this does not work. Eclipse complains when I use this.
Do you think this is the best way to do ?
What you probably want is:
String myUrl = getString(R.string.my_url);
The getString() method is in Context which means that it's available directly in your Activity class since Activity is a subclass of Context. (The getString() method is also in Resources but it's easier to call on it directly on your Activity.)
What happens with your XML resources is that each is given a unique integer ID and this is added to the automatically generated R class as a public static final int. You then use these IDs to reference the resources. Have a look in the gen folder in your Eclipse project and you'll find the R class in there.
Do you ever refer this page: https://developer.android.com/guide/topics/resources/available-resources.html ?
If you want to retrieve the String represented by a resource ID, you can call the Context.getString() method.
Or, you have to post Eclipse's complains.

Categories

Resources