Android Studio does not start

Have you just downloaded and installed the new Android Studio? And it will not start after the installation? Here is the solution:

You are most likely missing the JDK_HOME environment variable. It should be pointing to your java JDK installation, for example C:\Program Files\Java\jdk1.7.0_21\

If you haven’t installed Java JDK 7, you can download it from Oracle here.

Google Play: How to filter out your app for specific devices only

If you are publishing an Android app that should only be available to a specific device, like my new Ambient Temperature Galaxy S4 app does, you can use this method to help narrow down which devices it will be available on, in Google Play store.

This applies to your AndroidManifest.xml file in you app project:

First of all, you can set the minSdkVersion to the sdk version that the Galaxy S 4 is shipping with, which is Android 4.2.2 (API level 17)


<uses-sdk
 android:minSdkVersion="17"
 android:targetSdkVersion="17" />
 <uses-feature />

Then, you can set the compatible-screens filter, you better match the screen of your target device(s). For example, the Galaxy S4 has a screen density (dpi) of 480!


<!-- filter for sgs4: -->
 <compatible-screens>
 <screen
 android:screenDensity="480"
 android:screenSize="normal" />
 </compatible-screens>

This applies to the APK settings in you Google Play developer console:

In the Google Play developer console, where you upload you new .apk files, you can select “See supported devices”, to see which devices your app is compatible with.  From there, you can further narrow down the devices, by simply deselecting them.

google-play-device-filter2 google-play-device-filter

 

These tricks should help you narrow down the target of you app, if your app is only made for a handful of devices.

ic_launcher

“Ambient Temperature Galaxy S4″ Android app released to Google Play!

May 7, 2013 my app called Ambient Temperature Galaxy S4 was released to Google Play.

This is a thermometer app which measures the ambient temperature, instead of the battery temperature (as many of the other apps does).

For the thermometer app to work, you have to have a device with a thermometer, as of right now, the only device I can think of that has one, is Samsungs Galaxy S4.   This is a real thermometer app, for a real thermometer sensor.

Note: I could not find a way to filter out this app for Galaxy S4 devices only, it seems to be a  limitation in the Android uses-permission system, in the androidmanifest.xml file, which prevents this.

App Features

With the app, you can view the outside temperature (not the battery temperature!) of your device.  You can change between Celcius and Fahrenheit degrees by clicking on it.

The app will keep track of the maximum and minimum temperature (even if you exit the app and open it later), and the max and min temperature can be reset by hitting the menubutton.

The app does NOT contain ads, and it does not require any permissions at all!

More features may be added later.

Screenshots

temp1

Screenshot_2013-05-09-10-06-11

temp2

Feedback

If you have any feature requests, feedback or anything, feel free to comment below.

If you like the app, please share, and rate it, thank you :)

Link to the app in Google Play

sgs4-featured2

A Mini Review of Samsung Galaxy S4

This is a small review of the Galaxy S4, as I experience it coming from the S3 with a custom rom, CyanogenMod 10.1.

I will update this post as I encounter more positive or negative things.

Pros:

  • Great great 1080p screen! Very clear, bright and high pixel density makes it easy to read text and look at the screen.
  • Snappy processor makes task switching and app launching immediate!
  • Battery life is good. One charge got me through two days of light to medium usage.
  • You get 50GB extra space on your Dropbox account, for free, if you just log on with the  account. Which is nice to have, even though I already had 70GB and Im just using a small fraction of that.
    (If you need even more free space on your Dropbox account, you can take a look at this post)
  • Built in tracking of your phone, with the Samsung account

Cons/Potential:

  • Only 8-9 GB free space on the device. But I can always just insert a 32GB microsd card to make ut for that.
  • I hate bundled apps that cannot be uninstalled. And there are a few of them (for example, see the images on the right. And thats not all of them). included-apps included-app-blurb
    I really wish most of them were installed through the market, so I could remove them without rooting the device.
  • TouchWiz. Having Samsungs custom gui on top of Android will create a delay of upcoming Android updates to the Galaxy S4, compared to the Nexus devices which get updates straight away.
  • Coming from the Galaxy S3, Im used to the plastic body, which is almost the same as on the SGS4, but I would like to see a better build quality.
  • Too much syncing as a default. Browser bookmarks, settings, messages, notes etc is set up to sync as default with the samsung account.

I must admit I don’t use all of the extra gimmicky features, like eye-scrolling, pausing movie playback while looking away, air gestures and fingerhovering for selection.

Edit: There are lots of included apps, not just Samsungs own apps, which are quite a few, but also games (Com2uSPoker, Match3VS + others), travel apps (TripAdvisor + others), checkout app (Blurb for ordering stuff, HP Printing Service, finance apps (from Yaahoo) and more. Most apps can be disabled in the application manager, but are still stealing storage space.

What am I missing from Galaxy S3 with CyanogenMod 10.1?

There are some small details, that I used almost every day, that I am immediately missing, coming to Galaxy S4 from the S3 running a custom rom.

  • The ability to automatically connect to 3G while sending an MMS, before disconnecting again.
  • No bundled apps
  • Clean standard Android gui and standard Android apps (dialer, contacts, etc)
  • Open camera from lockscreen (when using pin security)
  • Slide your thumb across the top taskbar to adjust screen brightness
  • Ability to set a different notification light for different apps, for example green light for sms, red for GMail, blue for Facebook notifications. I found this quite handy when I got used to it.

What am I NOT missing from Galaxy S3 with CyanogenMod 10.1?

  • All the bugs and non-working features of the early versions

What’s your experience with the Galaxy S4? And what do you like or dislike with the device?

sgs4-featured

Samsung Galaxy S4 – Tips and Tricks

This is a post with different tips and tricks for the new Samsung Galaxy S4.

How to take a screenshot on Galaxy S4

There is no obvious way to take a screen dump on the Galaxy S4, but there are two methods:

  1. When you want to take a screenshot, swipe your hand across the screen (touching it), from one side to the other. (This also works on the Galaxy S3)
  2. Presss and hold the Home button and the Power button, for about one second.

The first method is a bit unreliable, as you might touch something on the screen unintentionally, for example start scrolling, and ruin the screenshot. The second method is the most reliable one.

Coming from the Cyanogenmod 10.1 on Galaxy S3, I guess Im just a bit spoiled with a separate menuitem on the power menu, for taking screenshots.

How to reveal the hidden menu for Developer options on Galaxy S4

On most Android devices, there is a hidden menuitem for developer options, which you can reveal with a simple trick. I have written a post about this before, here, and the steps are almost the same for the Galaxy S4:

sgs4-devmenu

  1. Go to Settings -> More -> About device
  2. Scroll to the bottom of the screen
  3. Press the “Build number” section 7 times.
  4. You will then see a message, and the “Developer options” menu item will become visible in the “More” tab!

In the developer options menu, you can enable debugging, and start develop and test apps on your device.

This also works on the Galaxy S3, although  the settings menu layout is just a bit different.

 

actionbar-home

How to notify your Fragment of different user navigation events

If you are using Android Fragments in your app, it can sometimes be useful to know when a user is navigation away from your fragment, so that you can act upon the users action, either by saving away data, asking the user for a confirmation, or what else.

Here I will describe three methods of registering navigation events.

Telling the Fragment that the back button has been pressed, through a reference to your fragment

If you would like to know that the user pressed the back button, you can get that information through a FragmentActivity.

Inside a FragmentActivity, we can override the onBackPressed method, and we can use this to notify the fragment that the user has pressed the back button. We can then act accordingly.

If we have an activity called DetailActivity:


public class DetailActivity extends FragmentActivity {

	private DetailFragment fragment;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_note_detail);
		fragment = new DetailFragment();

		getSupportFragmentManager().beginTransaction()
			.add(R.id.detail_container, fragment).commit();
	}

	@Override
	public void onBackPressed() {
		super.onBackPressed();
		fragment.backButtonWasPressed();
	}
}

And a fragment called DetailFragment:


public class DetailFragment extends Fragment {

	public DetailFragment() {
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// ...
	}

	public void backButtonWasPressed() {
		saveDataBeforeExiting();
	}
}

We can use the onBackPressed method in our activity, to call the backButtonWasPressed method that we created in the fragment. There, we can do what we want to do, when the backbutton is pressed.

Continue reading

admob-featured

Admob for Android gives error on AdActivity android:configChanges

After experimenting with Admob for Android, I came across an error with the example code that can be downloaded from the developer site about advertising.

The errors Eclipse gave me, was:

You must have AdActivity declared in AndroidManifest.xml with configChanges.

ads-example-error

and that android:configChanges had to include screenLayout, uiMode, screenSize and smallestScreenSize.

After modifying the AdActivity tag in the Manifest file, from:


<activity android:name="com.google.ads.AdActivity"
 android:configChanges="keyboard|keyboardHidden|orientation" />

to including the missing config parameters:


<activity android:name="com.google.ads.AdActivity"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

I then got another error at the AdActivity, saying:

Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').

All permissions and everything was set up right in the code example, except for the project build target.

Apparently, some of the required parameters, are not supported in Android API versions lower than 13, but the build target specified in the example project, is set to API level 8.

So, open the project.properties file, and change target=android-8  to target=android-13 (or higher).

The example project should now be compiling and working properly, and displaying ads as expected.

ads-example

If Eclipse is still complaining about the last error, re-save the manifest file, or just restart Eclipse.

Ps: Remember to use your own admob_id in the strings.xml file.