set default mock location data at DDMS - android

When using DDMS in eclipse to simulate location data I manually input the lat/lng value. Can I set default values for them so that I don't have to do it over after restarting my eclipse?

You can simply create command line batch file that will fix geo location. You can read how to do this here and here.
Update:
I've searched through the source codes of ddmlib. We can only laugh from the comment:
public class EmulatorControlPanel extends SelectionDependentPanel {
// default location: Patio outside Charlie's
private final static double DEFAULT_LONGITUDE = -122.084095;
private final static double DEFAULT_LATITUDE = 37.422006;
However, if you want you can change this values and rebuild the sources. This class is situated here:
android/sdk/ddms/libs/ddmlib/src/com/android/ddmlib/EmulatorConsole.java
I'm not very good at reflection, maybe it is possible to change this values through it.
I'm not sure but I think it is possible to add ddmlib.jar to your application and in your application set the values for yours location.
Good luck! If you manage to do this, please, write about your experience!

Related

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.

SkobblerMaps Android: How to create navigation log file

I want to simulate a drive using the SKNavigationSettings.SKNavigationType.FILE. Is there an easy way to generate one of these files? I see the Seattle.log in the demo project, and I could just edit some coordinates and make my own however it would be great to simulate a real drive. Also I am not sure what all of the entries are:
"47.655942 -122.137419, 11.000000, 19.000000, 0.000000, 1380803959889470, 03.10.2013 15:39:19" (what are 11.000000, 19.000000, 0.000000?)
Update: I still do not have a way of doing this and I do not understand some of the values (listed above). The file is Seattle.log and it just consists of a bunch of lines like the one above separated by newlines.
You can find the full SDK documentation here.
https://www.developer.skobbler.com/docs/android/3.0.2/index.html
Yes, you can obtain a logging file with data collected from a real drive. You can use the startLoggingPositions(String filePath, SPositionLoggingType positionLoggingType) and public boolean stopLoggingPositions() from the SKPositionLoggingManager class (com.skobbler.ngx.positioner.logging package) to accomplish that. You will obtain a log file (if the positionLoggingType is set to SK_POSITION_LOGGING_TYPE_LOG) similar to Seattle.log at the specified path.
The values stored in the file are (in this order): Latitude, Longitude, Course, Speed, Accuracy, Timestamp.

Static variable used in project android studio

How do i find where static variable are used in android studio project? Is there any way to find such variables . As my project is too big and i want to remove possible memory leaks. Help me to achieve this. Thanks
I have been using this trick for a very long time now. I am sure this will definitely help you. Follow the instructions step by step and this will help...
If you are using windows, Press Ctrl + Shift + F to open entire project search...
Next, In the text to find add this Regex (public|private|protected) static and under options select case sensitive and Regular expression. This will match public static or private static or protected static.
In the scope, select the project production files
Set the file mask as *.java
Set the context as except comments and string literals
When you hit Find, you will get 1000's of results. You will find results like this:
Completely ignore the usages in generated code.... IMPORTANT
Only search in the found occurences for your static variables.
PS :
One drawback with this is that this will match static methods too... such as public static int randomMethod() { }
If your static variables don't have access specifiers such as public private or protected, just use regex as static .
1.Open your andorid project.
2.Click ctrl+shift+f
You will get a dialog box.
Then search static
You will get all static members and functions.
You can do right-click on said variable and choose Find Usages:
Result will be revealed on Find panel on bottom-right of the window.

Eval function in Dalvik

If I know a variable's pattern such as R.id.edit_x where x (1..N), how can I get a reference to a given EditText, like findViewByID(R.id.edit_1). Is there something like an "eval" function in Dalvik ? Thanks.
Try Java reflection. Discussion on retrieving static final fields via reflection is here - Accessing Java static final ivar value through reflection
hoha's answer is good. Another thing you can do is create a look-up table that maps 1..N to the resource IDs. (Presumably you know all the resource IDs ahead of time.)
maybe, you can check roboguice. it is a ioc framework for android and it's realy easy to use. i copy some code from the sample from the project to show how to use it:
public class AstroboyMasterConsole extends RoboActivity {
#InjectView(R.id.self_destruct) Button selfDestructButton;
#InjectView(R.id.say_text) EditText sayText;
#InjectView(R.id.brush_teeth) Button brushTeethButton;
#InjectView(tag="fightevil") Button fightEvilButton; // we can also use tags if we want
}
then you can you these injected variables in your code!

Settings variable in Android

Is there a way to have an global settings variable for an android application, which is accessable as well from any help java classes without giving them context?!
I try to explain what I mean.
I have an application version as string value in strings.xml
I can get its value from every android activity, but not from help java classes withought giving context
What I do now, is saving it in a static variable of my first activity, but it seems, that sometimes it will be erased and set to null.
May be I do something wrong?!
Sorry for newbie question.
And thank you in advance,
Mur
P.s.
I wrote a small tutorial for this topic, to show the solution.
A variable declared as public, static, and final will be visible to all of your classes and never get erased.
public static final String VERSION = "1.2.3.4";
You could make a public static variable in your application class that you fill with the value from strings.xml in the onCreate method. The application class is a singleton and will be the last thing that is killed as part of your app so it will always be there and if you make it public static there will be only one instance.
I'm guessing that you have a JAVA class for some common utility functions. You get the value of your string using a context in your Activity/Service and then pass in that value to the JAVA class function as a parameter.

Categories

Resources