Tag: java

Notifications disappear as soon as service ends

I’ve got a service that scrapes a website for data then if necessary gives the user a notification. The problem I’m having is that the notifications disappear as soon as the service closes (which could be instantly). The below code is all of the notification code the app has. I haven’t put in any code […]

Websocket Server Android

Does anyone know of a free/open source websocket server that can be used for android? A light-weight Java one (hopefully) would work as well.

Android ViewGroup.setScaleX() cause the view to be clipped

I use NineOldAndroids library to scale my custom layout. public class MyLayout extends FrameLayout { // LayoutParams.MATCH_PARENT and all. … @Override public boolean setPositionAndScale(ViewGroup v, PositionAndScale pas, PointInfo pi) { … mScale = pas.getScale(); ViewHelper.setScaleX(this, mScale); ViewHelper.setScaleY(this, mScale); } } I have tried FrameLayout and AbsoluteLayout. All have the same effect. When mScale < 1.0 […]

how to access com.android.internal.telephony.CallManager?

I am trying to access CallManager class object from com.android.internal.telephony package. Here is my code: ClassLoader classLoader = TestActivity.class.getClassLoader(); final ClassLoader classLoader = this.getClass().getClassLoader(); try { final Class<?> classCallManager = classLoader.loadClass(“com.android.internal.telephony.CallManager”); Log.i(“TestActivity”, classCallManager); } catch (final ClassNotFoundException e) { Log.e(“TestActivity”, e); } Unfortunately, this is throwing a ClassNotFoundException. The same approach allows me to access […]

Null Pointer in getApplicationContext()

I’m trying the following piece of code, where a service is implementing my listener: public class MyListenerClass extends Service implements MyListenerInterface { public void onCurrencyRecieved(MyEventClass event) { System.out.println(“Coins Recieved – Listener Successful”); stopSelf(); Toast toast = Toast.makeText(getApplicationContext(), “Service Stopped”, Toast.LENGTH_LONG); toast.show(); } @Override public void onCreate() { Toast toast = Toast.makeText(getApplicationContext(),”Service started”, Toast.LENGTH_LONG); toast.show(); super.onCreate(); […]

NDK support is an experimental features and all use cases are not yet supported error in Android Studio?

I want to integrate NDK into Android studio but i am facing NDK support is an experimental feature and use cases are not yet supported error.I have downloaded NDK using the SDK manager and the NDK is palced C:\Users\The\AppData\Local\Android\Sdk\ndk-bundle. I have also created NativePanorama java class for Java and C++ interaction. Here is the code […]

Are all .class files in my Java application loaded into memory after appliaction start?

I am making an app for Android, in my Activity I need to load an array of about 10000 strings. Loading it from database was slow, so I decided to put it directly into one .java file (as a private field). I have about 20 of these classes containing string arrays and my question is, […]

Porting an SDL 2.0 game to Android

I have a game written in C/C++ with SDL 2.0, I would like to port it to mobile platforms (specifically Android and maybe other platforms too). I read SDL has a native support for Android but the game itself is written for Windows at first, although no Windows-dependent libraries/code were used. As for Android, I […]

How to include dependencies in android library gradle project?

I’m building an android library project with Gradle using Android Studio. It has some local dependencies: compile project(‘:androidlibrary’) with nested, additional external dependencies: compile group: ‘com.google.guava’, name: ‘guava’, version: ‘14.0.1’ I managed to build the aar file but no external or local dependencies are included. I expect external dependencies to be mentioned in the POM […]

Using Scala with Java in Android Studio

I installed the 1.5.2 Scala plugin in Android Studio 1.2.2. I have an existing (functioning) project coded in Java. I added a trivial class in Scala to replace an existing Java class just to try it out. The IDE seems to validate the Scala code but the reference to the class from the Java code […]

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