Tag: java

How to change package name of an Android Application

My keystore is corrupt, therefore the Android Market is requiring me to rename the app and resubmit it. However, whenever I go to edit the package names in Manifest and throughout the files, it gives me tons of errors. What’s the proper way to change the application name?

Android Layout with ListView and Buttons

Alright, this specific layout is just annoying me. And can’t seem to find a way to have a listView, with a row of buttons at the bottom so that the listview doesn’t extend over top of the buttons, and so the buttons are always snapped to the bottom of the screen. Here’s what I want: […]

How can I get the current screen orientation?

I just want to set some flags when my orientation is in landscape so that when the activity is recreated in onCreate() i can toggle between what to load in portrait vs. landscape. I already have a layout-land xml that is handling my layout. public void onConfigurationChanged(Configuration _newConfig) { if (_newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { this.loadURLData […]

Android – Writing a custom (compound) component

The Android app I’m currently developing has a main activity that has grown quite large. This is mainly because it contains a TabWidget with 3 tabs. Each tab has quite a few components. The activity has to control of all those components at once. So I think you can imagine that this Activity has like […]

Base 64 encode and decode example code

Does anyone know how to decode and encode a string in Base64 using the Base64. I am using the following code, but it’s not working. String source = “password”; byte[] byteArray = source.getBytes(“UTF-16”); Base64 bs = new Base64(); //bs.encodeBytes(byteArray); System.out.println( bs.encodeBytes(byteArray)); //bs.decode(bs.encodeBytes(byteArray)); System.out.println(bs.decode(bs.encodeBytes(byteArray)));

Can I do a synchronous request with volley?

Imagine I’m in a Service that already has a background thread. Can I do a request using volley in that same thread, so that callbacks happen synchronously? There are 2 reasons for this: – First, I do not need another thread and it would be a waste to create it. – Second, if I’m in […]

Prevent Android activity dialog from closing on outside touch

I have an activity that is using the Theme.Dialog style such that it is a floating window over another activity. However, when I click outside the dialog window (on the background activity), the dialog closes. How can I stop this behaviour?

How to make a copy of a file in android?

In my app I want to save a copy of a certain file with a different name (which I get from user) Do I really need to open the contents of the file and write it to another file? What is the best way to do so?

Resize image to full width and fixed height with Picasso

I have a vertical LinearLayout where one of the items is an ImageView loaded using Picasso. I need to rise the image’s width to the full device width, and to display the center part of the image cropped by a fixed height (150dp). I currently have the following code: Picasso.with(getActivity()) .load(imageUrl) .placeholder(R.drawable.placeholder) .error(R.drawable.error) .resize(screenWidth, imageHeight) […]

Typical .gitignore file for an Android app

Just put an Android project under git (beanstalk) version control via the command line (mac terminal). Next step is to set up exclusions. To those of you who have already been down this path: What should a typical .gitignore file look like for an android project? Project set up in Eclipse

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