Tag: java

How to calculate position on a circle with a certain angle?

I’m trying to figure out how I could be able to calculate coordinates on a circle. For simplicity I made some images. That’s the start with information I have. Now I need to calculate the new coordinates when for example the circle would turn 90 degrees to the right. Just like the next image: I […]

How do I load my own Java class in C on Android?

I am trying to call some Java code that I wrote from C using the Android NDK. The application is a NativeActivity application. I have to access some functionality that is only available in Java, and the functionality requires you to subclass another class, so I can’t just directly do the calls from C. Thus, […]

<? extends A> won't accept A's child classes

I’m working with Android Studio and I keep getting a problem I don’t know how to solve. I don’t know whether it’s a problem with Android Studio, with Java or a mistake a make. I have a class whose constructor is the following: public MakeQuery(Callable<ArrayList<? extends A>) { … } I try to create an […]

onDestroy() while “waiting” for onActivityResult()

I have an app with two activities: “A” and “B”. “A” uses startActivityForResult() to spawn “B” i.e. it waits for “B”. Now, assume that “B” is in foreground. Can the Android system destroy activity “A” without also destroying “B”? (If yes, then when “B”is finished e.g. after user input, activity “A” must be recreated and […]

java.net.ConnectException: failed to connect to /192.168.253.3 (port 2468): connect failed: ECONNREFUSED (Connection refused)

I want to transfer some data between PC and a mobile phone with wifi, but I got “java.net.ConnectException: failed to connect to /192.168.253.3 (port 2468): connect failed: ECONNREFUSED (Connection refused)” when I run my android project. This is how I get the wifi ip address: String ip = String.format( “%d.%d.%d.%d”, (wifiInfo.getIpAddress() & 0xff), (wifiInfo.getIpAddress() >> […]

Android Preference Screen Layout

I have the following preference screen in my app <PreferenceScreen xmlns:android=”http://schemas.android.com/apk/res/android”> <EditTextPreference android:key=”edittexvalue” android:id=”@+id/edittextvalue” android:title=”Title Here” android:summary=”Summary Here” android:defaultValue=”Some Value”/> <Preference android:key=”customPref” android:title=”Title Here” android:summary=”Summary Here”/> </PreferenceScreen> All of that works just fine however my app i have custom backgrounds and text colors/sizes but i can’t figure out how to format the PreferenceScreen I assume […]

Cannot cast from ActionProvider to ShareActionProvider

I am trying to implement a ShareActionProvider in my ActionBarSherlock. The following code gives me this error : Cannot cast from ActionProvider to ShareActionProvider ReadingActivity.java @Override public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.menu2b, (Menu) menu); menu.getItem(0).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS|MenuItem.SHOW_AS_ACTION_WITH_TEXT); menu.getItem(1).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS|MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem menuItem = menu.findItem(R.id.share); // Get the provider and hold onto it to set/change the […]

Using SQLite from libGDX on Android

Does anyone have any tips on storing data from libGDX on Android in SQLite. I am very familiar with the techniques used in the Android SDK but I don’t have any idea how to call those Android database functions from libGDX. I know that calling the functions from libGDX will make my game unusable on […]

Android RecyclerView LayoutManager Exception

Hi I’m having an issue with the new Android Lollipop RecyclerView It keeps crashing with the following exception: Attempt to invoke virtual method ‘void android.support.v7.widget.RecyclerView$LayoutManager.onMeasure(android.support.v7.widget.RecyclerView$Recycler, android.support.v7.widget.RecyclerView$State, int, int)’ on a null object reference Full stack trace can found here The code used to initiate the RecyclerView is the same mostly the same as the tutorial, […]

Pass variables between renderer and another class with queueEvent()

I want to pass my renderer some values from another class. After the renderer has calculated the values, I have a mutex in a helper class that should tell me that the renderer has finished calculating so I can continue with these new values. I can pass the renderer the values without problems, but I […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.