get Custom ROM name

Recently we had serious problems with testing some code at one client’s device that was running custom Android ROM. App was crashing due to missing libraries that didn’t come with custom ROM and both client and us didn’t know which ROM was on a device.

All that you can get from reading android.os.Build properties isn’t enough to determine which ROM device has, as it’s not guaranteed that ROM entered its description/name into any of its fields.

Here’s Java code snippet that you can use to grab custom ROM name. It worked nice with all sorts of CyanogenMod.

private String getCustomRomVersion()
{
	String modVer = 
		getSystemProperty("ro.modversion");
	return 
	(modVer == null || modVer.length() == 0 ? "Unknown" : modVer);
}
	
private String getSystemProperty(String propName)
{
	String line;
	BufferedReader input = null;
	try
	{
		Process proc = Runtime.getRuntime()
				.exec("getprop " + propName);

		input = new BufferedReader
		(new InputStreamReader(proc.getInputStream()), 1024);

		line = input.readLine();
		input.close();
	}
	catch (IOException ex)
	{
		return null;
	}
	finally
	{
		if (input != null)
		{
			try
			{
			   input.close();
			}
			catch (IOException e)
			{
			   //
			}
		}
	}
	return line;
}

Just call getCustomRomVersion() and read String output. If it’s Unknown, it should be non-rooted non-custom ROM, so you can read version name and other info from android.os.Build. Otherwise, it should return custom ROM name.

Tagged , ,

Flip between two Activities

Let’s say there’s no realistic-enough way to do real flip between Android Activities that we are so far aware of.
However, when we wanted to do such animation effect, we came to this solution:

Ensure you have /res/anim folder created within your Android project.

You will have to create two XML files that will define animations that simulate flip effect, and then you can use common overridePendingTransition(animation,animation) method.

/res/anim/flipfadein

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
    android:duration="300"
    android:fromXScale="1.0"
    android:fromYScale="0.0"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:pivotX="50%"
    android:pivotY="50%"
    android:startOffset="500"
    android:toXScale="1.0"
    android:toYScale="1.0" />

<alpha
    android:duration="1"
    android:fromAlpha="0.0"
    android:startOffset="500"
    android:toAlpha="1.0" /></set>

/res/anim/flipfadeout

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
    android:duration="500"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="1.0"
    android:toYScale="0.0" />

<alpha
    android:duration="1"
    android:fromAlpha="1.0"
    android:startOffset="500"
    android:toAlpha="0.0" /></set>

Add
overridePendingTransition(R.anim.flipfadein, R.anim.flipfadeout);
after startActivity or finish() lines, and there you go.

Now, when it’s about tweaking xml parameters, you will notice that these provide “flip” over x axis (horizontal axis). If you want it to be y (vertical) axis, just revert values of
android:toXScale=”1.0″, android:toYScale=”0.0″
to
android:toXScale=”0.0″ android:toYScale=”1.0″
Playing with this values could probably make it rotating over arbitary axis.

Durations are set to 500 in fadeout and 300 in fadein because it seems to “feel” more “flip” when flip in runs a bit faster. Feel free to change these, and to submit modifications in comments.

Tagged , , ,

Custom Animation while switching between Activities

It’s quite simple after all.
What you have to do is to call overridePendingTransition(int enterAnimation, int exitAnimation) immediately after startActivity(Intent) or finish() to specify an explicit transition animation to perform next.

You will have to create anim folder within res folder (if you already didn’t do it). In /res/anim/ add XML files that are representing single Animations.

Here are some common Animations that you can simply copy and paste separately into XML files:

/res/anim/left_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/linear_interpolator">
  <translate
      android:fromXDelta="0"
      android:toXDelta="-100%p"
      android:duration="500"/>
</set>

/res/anim/right_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="500"/>
</set>

/res/anim/bottom_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromYDelta="100%p"
android:toYDelta="0"
android:duration="500"/>
</set>

/res/anim/top_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromYDelta="0"
android:toYDelta="-100%p"
android:duration="500"/>
</set>

/res/anim/fade_in.xml

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="800"
android:repeatCount="0" />
</set>

/res/anim/fade_out.xml

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="800"
android:repeatCount="0" />
</set>

Duration, repeatCount, and other values are on your behalf to modify to your preference.

Now, all you have to do is to put this kind of line of code after startActivity(Intent) or finish()
overridePendingTransition(R.anim.right_in, R.anim.left_out);

Play with two Animation parameters until you get transition effect that suits you. Also, if you have another ideas for XML transitional files, post them in comments so we could add them to a list above.

Tagged , , ,

Eurovision 2012 Video Player – retrospective

In April 2012 we wanted to publish some simple yet effective Youtube player app. That app would stream and play any Youtube videos by their given ID codes, and that’s it. So the smart part was coded a long time ago, and honestly speaking, much of it is open-sourced code available pretty everywhere online.

But we wanted to check if Android users actually need an app which would consist a playlist of Youtube videos, hard-coded so users can’t add new videos, nor remove them, not even sort them. And Eurovision is a big event in Europe, for those of you who didn’t know that. Simple search on Google Play gave no opponents to such an app which would have all contestants of Eurosong 2012 listed with their songs. So that’s why we made Eurovision 2012 Video Player. Believe it, it was a really simple job, and such app makes you headache only because you have to do much of extremely boring copy/paste work. And some GIMP thumbnails proccessing. But that’s it.

So the link to download is here:

https://play.google.com/store/apps/details?id=com.dualquo.te.eurovision

See, it was published on April 11th, and Eurovision was scheduled between 20th and 26th of May. So some 40 days before the final competition days. Funny enough, people seem to prefer this simple apps over smart stuff. Good for us developers. This app got more than 5000 downloads in the first month, and currently holds 10000 – 50000 downloads. Roughly, level of active downloads was about 65% before Eurovision finals, but nowdays it constantly goes down in numbers, and is around 40%, if not less.

However, conclusion was simple. Make some simple app, that could be cloned fast, and that users simply need because they are lazy. In this case, factor was congregation of all videos at one place, within the app. Smart apps with lots of work behind them simply don’t have to be successful at all.

And Eurovision 2012 Video Player is definitely going into hybernation, until it mutates into Eurovision 2013 Video Player, but starting at this high number of downloads. So lets see how it’s going to be then.

Flickr my Wallpaper

Flickr my Wallpaper

This is the second Live Wallpaper published by QUO?TE developers.

Flickr my Wallpaper, pimps your Android wallpapers with Flickr photos.

Set your Flickr tag and tagged photos will populate your wallpaper desktop, hourly or randomly, depends on how you set it. If you don’t set up tag, daily most interesting Flickr voted photos will be downloaded, one by one.

Remember that this is only the first version, so have mercy in rating, and no mercy in suggesting improvements :)

Tagged , , , ,

Words of Love Live Wallpaper

Actually, our first baby app on Android market. Of course, free.

https://play.google.com/store/apps/details?id=com.dualquo.te.threesweetwords

Not really so serious attempt to take over the market, but more interesting (and definitely more useful) apps are to come soon.

If this app deserves attention and comments, throw us some lines. At least, whatever you suggest that is about improving the app, we will probably implement sooner or later.

Follow

Get every new post delivered to your Inbox.