Thursday, October 31, 2013

Incorrect localization of markers on map. Strange behaviour of markers on the map [android help]


Incorrect localization of markers on map. Strange behaviour of markers on the map



I works with OSMdroid. I extended the Overlay class and I overridden the draw method to my needs. And I have a problem with placing of markers. When I display them for the first time they have wrong location. But when I start zooming they move and after couple of zooms they have correct localization.


Here is my code:



protected final Rect mRect = new Rect();
protected Point mScreenPts = new Point();

@Override
protected void draw(Canvas c, MapView osmv, boolean shadow) {
Projection pj = osmv.getProjection();

synchronized (mInternalItemList) {
if (shadow && !mInternalItemList.isEmpty()) {
for(int i = 0; i < mInternalItemList.size(); i++) {
CustomizedItem customized = mInternalItemList.get(i);

pj.toMapPixels(new GeoPoint(customized.getLatitude(),
customized.getLongitude()), mScreenPts);


boundToHotspot(customized.getDrawable(), HotspotPlace.LOWER_LEFT_CORNER);

Drawable draw = customized.getDrawable();

draw.copyBounds(mRect);
draw.setBounds(mRect.left + mScreenPts.x, mRect.top + mScreenPts.y,
mRect.right + mScreenPts.x, mRect.bottom + mScreenPts.y);

draw.draw(c);
draw.setBounds(mRect);
}
}
}
}


Thank in advance.



Read more

stackoverflow.comm



Android JUnit testing not firing test methods [android help]


Android JUnit testing not firing test methods



I don't know if I'm really rusty with JUnit or their is a concept with Android Testing in particular I'm not familiar with but:


I'm finding it very difficult to understand how my tests get run.


I've created a Test Project based on my main project, and created a class which extends ActivityInstrumentationTestCase2 and in this Test Case I've implemented setUp(), testPort() and tearDown() methods.


When I run the project as a Android JUnit test it all tests correctly.


However, adding another class extending ServiceTestCase with the same setUp(), testStart() and tearDown() methods implemented, the test isn't performed.


Looking through the documentation I can't find anything which states how the tests are run, I'm assuming since their is no specific setup it done via reflection.


Given that as the case however, I don't understand the documentation on TestSuites or why my Service test case isn't running.


Am I the only one that's finding the usually very well written Android Documentation lacking when it comes to testing?



Read more

stackoverflow.comm



Need help transferring photos with a broken digitiser. [General]


Need help transferring photos with a broken digitiser.



I have a lg lucid4g and i need help transferring the photos to my computer but I'm having a hard time because my phone does not respond to my touch im guessing its the digitizer.
Is there anyway i can this without having to buy a new digitizer?
I tried a couple of software such as "android recovery, mobile trans and a few others but with no luck.



Read more

forum.xda-developers.com



Inflate layout inside LinearLayout [android help]


Inflate layout inside LinearLayout



In the app that I'm developing, I have a Menu with icons that is on the right and left edges of the screen, and it mantains there in all the app's activities.


What I've done is first create the "MenuView" class activity where are defined all the menu's icons and their onClickListeners. Then the layout for this activity. In the layout I stablished 2 linearlayout's wich are each one on the border's of the screen (These refers to the menu) and a LinearLayout with the blank space inside the columns, where the other activities must go.


MenuViewActivity.java



public class MenuViewActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_view);
...

((ImageView)this.findViewById(R.id.navButton)).setOnClickListener(launch_nav);

final OnClickListener launch_nav = new OnClickListener() {
@Override
public void onClick(View v) {
getBaseContext().startActivity(new Intent(getBaseContext(), Navigation.class));
}
};
...


menu_view.xml



xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.MenuViewActivity" >



layout="@layout/custom_tittlebar" >




android:id="@+id/lefthandmenu"
android:layout_width="85dip"
android:layout_height="match_parent"
android:layout_below="@id/title"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:background="@drawable/border_cut" >

... />
...


android:id="@+id/righthandmenu"
android:layout_width="85dip"
android:layout_height="match_parent"
android:layout_below="@id/title"
android:layout_alignParentRight="true"
android:orientation="vertical"
android:background="@drawable/border_cut" >

... />
...



android:id="@+id/activitycontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@id/righthandmenu"
android:layout_toRightOf="@id/lefthandmenu"
android:layout_below="@id/title"
android:orientation="vertical" >



So, what I must do now is to tell the program that other activities must go inside this last layout. For this, I do this in for example the Main class. I extend the activity to MenuViewActivity and the I inflate the layout.


MainClass.java



public class MainClass extends MenuViewActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);


LinearLayout inside_menu_view = (LinearLayout)findViewById(R.id.activitycontent);
View this_layout = getLayoutInflater().inflate(R.layout.main, inside_menu_view);
inside_menu_view.addView(this_layout);


But I'm getting an error on the logcat:



10-31 09:14:05.314: D/AndroidRuntime(1703): Shutting down VM
10-31 09:14:05.314: W/dalvikvm(1703): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-31 09:14:05.324: E/AndroidRuntime(1703): FATAL EXCEPTION: main
10-31 09:14:05.324: E/AndroidRuntime(1703): **java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainClass}: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.MenuViewActivity**
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.os.Handler.dispatchMessage(Handler.java:99)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.os.Looper.loop(Looper.java:130)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-31 09:14:05.324: E/AndroidRuntime(1703): at java.lang.reflect.Method.invokeNative(Native Method)
10-31 09:14:05.324: E/AndroidRuntime(1703): at java.lang.reflect.Method.invoke(Method.java:507)
10-31 09:14:05.324: E/AndroidRuntime(1703): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-31 09:14:05.324: E/AndroidRuntime(1703): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-31 09:14:05.324: E/AndroidRuntime(1703): at dalvik.system.NativeStart.main(Native Method)
10-31 09:14:05.324: E/AndroidRuntime(1703): **Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.MenuViewActivity**
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.view.LayoutInflater.createView(LayoutInflater.java:508)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-31 09:14:05.324: E/AndroidRuntime(1703): at com.example.MainClass.onCreate(MainClass.java:67)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-31 09:14:05.324: E/AndroidRuntime(1703): ... 11 more
10-31 09:14:05.324: E/AndroidRuntime(1703): **Caused by: java.lang.NoSuchMethodException: MenuViewActivity(Context,AttributeSet)**
10-31 09:14:05.324: E/AndroidRuntime(1703): at java.lang.Class.getMatchingConstructor(Class.java:643)
10-31 09:14:05.324: E/AndroidRuntime(1703): at java.lang.Class.getConstructor(Class.java:472)
10-31 09:14:05.324: E/AndroidRuntime(1703): at android.view.LayoutInflater.createView(LayoutInflater.java:480)
10-31 09:14:05.324: E/AndroidRuntime(1703): ... 19 more


UPDATE - After modofications still not working, this is the LogCat



10-31 09:35:17.521: E/AndroidRuntime(1676): FATAL EXCEPTION: main
10-31 09:35:17.521: E/AndroidRuntime(1676): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainClass}: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.MenuViewActivity
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.os.Handler.dispatchMessage(Handler.java:99)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.os.Looper.loop(Looper.java:130)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-31 09:35:17.521: E/AndroidRuntime(1676): at java.lang.reflect.Method.invokeNative(Native Method)
10-31 09:35:17.521: E/AndroidRuntime(1676): at java.lang.reflect.Method.invoke(Method.java:507)
10-31 09:35:17.521: E/AndroidRuntime(1676): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-31 09:35:17.521: E/AndroidRuntime(1676): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-31 09:35:17.521: E/AndroidRuntime(1676): at dalvik.system.NativeStart.main(Native Method)
10-31 09:35:17.521: E/AndroidRuntime(1676): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.MenuViewActivity
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-31 09:35:17.521: E/AndroidRuntime(1676): at com.masermic.medialauncher.LauncherActivity.onCreate(LauncherActivity.java:67)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-31 09:35:17.521: E/AndroidRuntime(1676): ... 11 more
10-31 09:35:17.521: E/AndroidRuntime(1676): Caused by: java.lang.reflect.InvocationTargetException
10-31 09:35:17.521: E/AndroidRuntime(1676): at java.lang.reflect.Constructor.constructNative(Native Method)
10-31 09:35:17.521: E/AndroidRuntime(1676): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-31 09:35:17.521: E/AndroidRuntime(1676): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-31 09:35:17.521: E/AndroidRuntime(1676): ... 19 more
10-31 09:35:17.521: E/AndroidRuntime(1676): Caused by: java.lang.NullPointerException
10-31 09:35:17.521: E/AndroidRuntime(1676): at com.mexample.MenuViewActivity.(MenuViewActivity.java:55)
10-31 09:35:17.521: E/AndroidRuntime(1676): ... 22 more


Read more

stackoverflow.comm



Using Wi-Fi only for android? [General]


Using Wi-Fi only for android?



Not sure if this is the right area to post this, so apologies if it's not. :P
I'm sick of dealing with Straight Talk putting me on a constant throttle, to the point where I've been averaging 2kbs per second since Saturday. That's not just throttle, that's unusable. I want to go another route and use Wi-Fi only. I get Wi-Fi nearly everywhere I go except home (and a Tracfone in case I'm in need of a phone and out of range of Wi-Fi), so I'm looking for a good internet provider. I wouldn't use much, if any, data on the computer, it'd be 99%-100% for my android only. I'd use VoIP services so my android can still be everything an android can be. Plus, I wouldn't have to worry about finding an unlocked phone online when buying a new one. Unlocked or not, it'd still work fine with the Wi-Fi/VoIP method. What provider do you know or have used that:
Either has unlimited data (preferred) or a lot of data (like 10gbs).
Is decently fast. Anything faster than a megabyte per second is fine by me. Hell, at this point, even 200kbs per second would often be faster than what I get). I'm not looking for speeds that would download a whole freakin movie in 5 seconds, but a decent speed that doesn't make me want to throw my phone out the window.
I'm currently looking at Wild Blue satellite internet, which is $60 for 10gbs and is fast (supposedly). But I don't know what people think of that company.
I know zilch about any of this so ANY info is appreciated!!



Read more

forum.xda-developers.com



New LG G2 [General]


New LG G2



I just bought a G2, i'm having trouble with notification sounds. I set the notification sound to something other than that annoying choir boys one. So receipt of texts, emails etc. give me the notification sounds I set them to. However, every time I call or text someone, I get a notification window from giffgaff showing my remaining balance/minutes/texts, and for some reason I still get the choir boys' "life is good" along with that. Same thing happens when I request remaining minutes from giffgaff. It's really irritating, does anyone know how to change it?



Read more

forum.xda-developers.com



Change "take screenshot" from Power+Home to Power+VolDown [General]


Change "take screenshot" from Power+Home to Power+VolDown



"Most phones are Phone + Home."

I guess I wouldn't know about "most", but the Galaxy Nexus 4G I'd used before was Power + Volume Down, and according to general web searching that was the standard combination for 4.0. Not sure what's happened since. Of course, which way is more common isn't too much of a concern

"Are you just rooted or running a custom ROM."

Just a rooted stock ROM at the moment. I may move to cyanogen when there's a 10.2 stable, but there's some things I like about touchwiz (like screen "smart stay" and custom lock screen shortcuts, a few other things), other things I like about CM (closer to android mainline and pretty much lets me do WTF I want), so not sure which I'll end up with. But just stock for now.



Read more

forum.xda-developers.com



Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...