Tag: java

Working POST Multipart Request with Volley and without HttpEntity

This is not really a question, however, I would like to share some of my working code here for your reference when you need. As we know that HttpEntity is deprecated from API22 and comletely removed since API23. At the moment, we cannot access HttpEntity Reference on Android Developer anymore (404). So, the following is […]

Android (JSONObject) How can I loop through a flat JSON object to get each key and each value

My ques. is simple yet no one has asked it nor answered it. I have a flat JSON: {“number1″:”value1”, “number2″:”value2”, “number3″:”value3” } I can set it to a JSONObject just fine. However, I don’t know how to loop through each item and get its key string and value string. Can anyone provide an efficient code […]

BitmapFactory.decodeStream returning null when options are set

I’m having issues with BitmapFactory.decodeStream(inputStream). When using it without options, it will return an image. But when I use it with options as in .decodeStream(inputStream, null, options) it never returns Bitmaps. What I’m trying to do is to downsample a Bitmap before I actually load it to save memory. I’ve read some good guides, but […]

can't call String.isEmpty() in android

In my android application I can’t use String.isEmpty() function which is situated in JDK 1.6. Android 2.1 lib doesn’t have this function in java.lang.String class I tried to input JRE System library to my project, because it has this function, but there was no effects. How can I solve this problem and allow my application […]

How to activate “Share” button in android app?

i want to add “Share” button to my android app. Like that I added “Share” button, but button is not active. I click, but nothing happens. My code in MainActivity.java: private ShareActionProvider mShareActionProvider; @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.share_menu, menu); getMenuInflater().inflate(R.menu.main, menu); MenuItem item = menu.findItem(R.id.share_menu); mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.share_menu).getActionProvider(); mShareActionProvider.setShareIntent(getDefaultShareIntent()); return true; } […]

'android-24' requires JDK 1.8 or later to compile

I use Android Studio and recently got the error: Error:Execution failed for task ‘:app:compileDebugJavaWithJavac’. compileSdkVersion ‘android-24′ requires JDK 1.8 or later to compile. But I have JDK 1.8 installed already: :\Users..>java -version java version “1.8.0_91” Java(TM) SE Runtime Environment (build 1.8.0_91-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b15, mixed mode) How to fix it? Thanks

Navigation drawer item icon not showing original colour

I’m trying to show an icon next to an item within my menu for my navigation drawer, but for some reason the icon always appears in grey rather than the original colour (brown). Is there any way of preventing this from happening in order to show the icon’s original colour? MainActivity.java public class MainActivity extends […]

Subscript and Superscript a String in Android

How can you print a string with a subscript or superscript? Can you do this without an external library? I want this to display in a TextView in Android.

How to set focus on a view when a layout is created and displayed?

Currently, I have a layout which contains a Button, a TextView and an EditText. When the layout is displayed, the focus will be automatically put on the EditText, which will trigger the keyboard to show up on Android phone. It is not what I want. Is there any way that I can set the focus […]

Android N Java 8 features (Jack compiler) and Kotlin interop

Update 3. KOTLIN IS NOW OFFICIALLY SUPPORTED FOR ANDROID DEVELOPMENT. BY GOOGLE. YAAAAAAAAS! Update 2: It looks like JetBrains is really committed to supporting Kotlin for Android in the long run. I’m a happy kotlin user :). Update: Hadi Hariri, from JetBrains, mentioned they’re going to release some info on this topic. I will update […]

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