HockeyApp is a crash reporting/analysis tool for iOS, Android, OS X and Windows platforms supported by Microsoft for one and a half years approximately.

We use HockeyApp for tracking crash reports in several android games and were using 3.5.0 version. They announced 4.0.0 stable version a week ago which include reporting of impacted % crash free user data. This is really a wonderful feature you can track success of your new releases which some other crash reporting tools like Crashlytics already have for years.

After this good news, it is time to upgrade our hockeyapp sdk version to 4.0.0. In 3.5.0 version, there was only a jar file you can easily import into your project. HockeyApp guys created an android archive (aar) for the version 4.0.0 which include some resources, localization texts used in Feedback, Authentication, built-in version update features. If you don’t use these features and only want to get crash reports and user metrics, you don’t have to use aar package. But where is the HockeySDK-4.0.0.jar? It is in the aar package.

Firstly download HockeySDK-Android-4.0.0.zip file. After unpacking the zip file, you will see HockeySDK-4.0.0.aar file in libs directory. Change file extension to “zip” and unzip aar package :

Using HockeyApp SDK 4.0.0 as jar

Get those “classes.jar” file and change the name to “hockey-sdk-4.0.0.jar”. Replace your existing hockeyApp sdk jar with new one. If you are planning to use hockeyapp sdk as jar, you can follow “Code Changes” part.

Converting HockeyApp 4.0.0 aar file to android library project

Ok, you don’t want to use HockeyApp sdk as jar.

1. Cretae an empty “src” named folder in the root of your “HockeySDK-4.0.0” directory and put a dumy readme file into it.

2. Create a local.properties file in the root of your “HockeySDK-4.0.0” directory and define your android sdk path etc as follows :

sdk.dir=C:\\...\\sdk
renderscript.opt.level=O0
java.source=1.7
java.target=1.7

3. Create a project.properties file in the root of your “HockeySDK-4.0.0” directory :

target=android-22
android.library=true

4. Move “classes.jar” into libs directory.

5. One last thing is to tell your android project that “HockeySDK-4.0.0” is a library project. Copy “HockeySDK-4.0.0” folder into libs folder of your android project and reference it in project.properties file of your android project.

android.library.reference.library_index=./libs/HockeySDK-4.0.0

Here “library_index” should be the index of this library as a digit for your application.

6. Finally if you are using ant for building your application, create build.xml file in the root of your “HockeySDK-4.0.0” directory :

<?xml version="1.0" encoding="UTF-8"?>
<project
    name="hockey-sdk"
    default="help" >

    <property file="local.properties" />
    <property name="java.target" value="1.7" />
    <property name="java.source" value="1.7" />
    <property file="ant.properties" />

    <property environment="env" />

    <condition
        property="sdk.dir"
        value="${env.ANDROID_HOME}" >

        <isset property="env.ANDROID_HOME" />
    </condition>

    <loadproperties srcFile="project.properties" />

    <fail
        message="sdk.dir is missing. Make sure to generate local.properties using &apos;android update project&apos; or to inject it through the ANDROID_HOME environment variable."
        unless="sdk.dir" />

    <import
        file="custom_rules.xml"
        optional="true" />

    <import file="${sdk.dir}/tools/ant/build.xml" />
</project>

Code Changes

You will probabely see some breaking changes. Only thing I have faced was the following :

net.hockeyapp.android.Constants class doesn't have "TAG" field anymore.

After fixing breaking changes, you are ready to implement user metrics for tracking crash free users. You only need to register MetricsManager in onCreate callback of your activity as follows :

MetricsManager.register(this, getApplication(), "YOUR_HOCKEYAPP_APPLICATION_ID");

If you have defined your hockeyapp application id in the manifest xml as shown below:

<application> 
  //your activity declarations and other stuff
  <meta-data android:name="net.hockeyapp.android.appIdentifier" android:value="@string/hockey_app_application_id" />
</application>  

then you can register MetricsManager without giving any application id.

MetricsManager.register(this, getApplication());

From now on, user metrics will ve reported and after crossing a threshold defined by HockeyApp guys, you will see some new UI about crash free users in your HockeyApp dashboard :)

Nowadays, it is so popular to send push notifications to clients including some sweet emojis for drawing attention and increasing the push notification click probability.

If you want to use emojis by holding your text in a string variable or constant, you can use directly in the following format.

String textWithEmoji = "This is your text with smile, \ud83d\ude03";

That’s ok, but where could we find these unicode form of emojis’?

http://www.charbase.com/block/emoticons

After clicking one of those emojis in the list, you can get and use “Java Escape” form directly.

Ok, this was really easy, but what if you want to get this string from strings.xml file. Bad news is that you can not use directly as “\ud83d\ude03”. After some investigation I have decided to use url encoded form of emojis in strings.xml and decode it before setting my notification’s title ot message.

On the same page you can see the url encoded form of emoji as follows :

q=%F0%9F%98%83

Just remove the “q=” part and store in the strings.xml file as shown below:

<string name="notification_emoji_smile">%F0%9F%98%83</string>

After reading the value from strings xml, you need to decode it. You can also combine it with another string from a variable or strings.xml.

String emojiString = context.getString(R.string.notification_emoji_smile);
String decodedEmoji = URLDecoder.decode(emojiString, "UTF-8");
String notificaitonMessage = "Hi guys, " + decodedEmoji;

Let’s say you found some emojis from another web site like this :

https://www.piliapp.com/emoji/list/

No problem, you can URL encode it and apply the same method above. You can use the following web site to URL encode emoji.

http://www.freeformatter.com/url-encoder.html#ad-output

That’s all, I wish happy emoji usages for everyone :)

My previous blog post was about integrating Unity Ads for a native android project using unity-ads android library project without aar package.

During the implementation phase, I faced some difficulties about reloading unity video ads and checking ad states. That’s why I am writing this post about example implementation and some tricks.

Example Implementation

First of all, you need to initialize Unity ads as you can guess by giving context as initialization parameter. Second parameters here is your game id which you can learn from unity ads games page.

You also need to give a listener for getting callback and some events about progress and completion.

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	....
	initializeUnityAds();
}

private void initializeUnityAds() {

	UnityAds.init(this, "YOUR_GAME_ID", new IUnityAdsListener() {
		@Overrides
		public void onHide() {
			Log.d("UnityAds", "onHide");
		}

		@Override
		public void onShow() {
			Log.d("UnityAds", "onShow");
		}

		@Override
		public void onVideoStarted() {
			Log.d("UnityAds", "onVideoStarted");
		}

		@Override
		public void onVideoCompleted(String rewardItemKey, boolean skipped) {
			Log.d("UnityAds", "onVideoCompleted");
		}

		@Override
		public void onFetchCompleted() {
			Log.d("UnityAds", "onFetchCompleted");
			Log.d("UnityAds", "You can show video if you want!");
		}

		@Override
		public void onFetchFailed() {
			Log.d("UnityAds","onFetchFailed");
			Log.d("UnityAds", "You can't show video even if you want!");
		}
	});
	if(UnityAds.canShow()) {
		Log.d("UnityAds", "You can show video if you want!");
	}
}

Most important part of this listener implementation is “onFetchCompleted” callback which means some video ads are loaded, cached into memory and you can show if you want. From now on,

UnityAds.canShow() 

method will return true.

If you want to see demo video ads during development phase, you can enable test and debug mode :

UnityAds.setDebugMode(true);
UnityAds.setTestMode(true);

After enabling debug mode, you can see Unity Ads logs but using “UnityAds” tag on logcat command.

adb logcat -s UnityAds

Your listeners “onFetchCompleted” method is called and your video is ready to show. Use this to show the video:

UnityAds.show();

After video has been completed or skipped, your listeners “onVideoCompleted” method is called. You can check skipped parameter for rewarding user or not.

Showing another video (Reloading video ad)

This is the part that I have faced some difficulties. I was expecting that onFetchCompleted method will be called after first video is completed. I have tried following methods for triggering this in my ad showing flow :

  • Called UnityAds.init(..) again after a video is completed.
  • Called nothing and waited for onFetchCompleted will be called :)

Unfortunately onFetchCompleted is not called automatically after a video has been completed and also calling init second time is not working. In “onVideoCompleted” method, ads are not ready to show yet and if you call UnityAds.canShow() here it return “false”.

You should use “onHide” callback of your listener for restarting your ad showing flow.

@Overrides
public void onHide() {
	if(UnityAds.canShow()) {
		Log.d("UnityAds", "Start your video show flow form beginning!");
	}
}

This “onHide” is called after user manually closes the ad. If you don’t want to use this callback, you should check “UnityAds.canShow()” in any time for ensuring on availability of vidoe ads.

If you want to integrate Unity Ads into your native android project but also don’t want to use android library for some reason, then you are in the right place to get some assist. I listed possible reasons of not using aar package in the following list.

  • Not using Gradle build system.
  • Using maven and facing issues while importing aar into your project.
  • Want to add unity ads as library project.

First of all, you need to download unity-ads android library project under unity-ads-sdk

Apply following steps to integrate unity ads library into your project.

1. After downloading unity-ads android library project, put unity-ads directory into libs folder in the root of your android project.

2. Cretae an empty “src” named folder in the root of your unity-ads directory.

3. Open local.properties file in unity-ads directory and,

  • tell the source code should ve compiled with java 1.7
  • Show your android sdk path in your local machine.
sdk.dir="C:\\..\\sdk"
renderscript.opt.level=O0
java.source=1.7
java.target=1.7

4. Open your project’s AndroidManifest.xml file and add “xmlns:tools=”http://schemas.android.com/tools” definition line under the “

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	  xmlns:tools="http://schemas.android.com/tools"
      package="..."
      android:versionCode="..."
      android:versionName="..."
      android:installLocation="auto">

5. Now you need to add unity ads activity into your applications manifest file, under the “" node as follows :

<application
	....
	>

	....
	....
	<activity
	    android:name="com.unity3d.ads.android.view.UnityAdsFullscreenActivity"
	    android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
	    android:hardwareAccelerated="true"
	    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
	    tools:ignore="UnusedAttribute" 
		/>

</application>

Now, you should be able to create an apk including unity ads resources and compiled codes using your build system.

If you want to learn how to implement unity ads on android, you can check this example implementation.

I hope this post is helpful for everyone.

You probably know that there is a place far away called “stackoverflow” if you are here to read this blog post. Developers from every aspect of programming live here and try to make scores, gain points & badges, complete some achievements. It is normal you think this is just a game due to many gamificated parts of it, but this is not.

You can see there is many job opportunities on the home page of stackoverflow and you can be sure many technology companies especially related to software development, consider stackoverflow scores of developers in addition to theirs CV and other criterias. So, stackoverflow is a serious sharing/asking/discussion area which every level of developer can benefit from.

Please up-vote and/or select one of the answers

Let’s say you have posted a question and got 3 answers after a while. You saw that second answer is the point that you didn’t realized about your issue. After 20 minutes then you have applied the suggestion to your question, everything is working well. OK, close the stackoverflow page and just continue to your life and be happy.

No way! Please open your stackoverflow page, open questions tab and find the question you asked. Now, you should up-vote second answer and select it for showing that this was the answer you expect and also this is the best answer for this question. So there are two happy people as you and the guy answered your question. Because he got 25 points for his/her answer.

Don’t forget that you have a post here…

You have posted a question about your issue and had a coffee break. You suddenly saw a light and found the answer you were looking for. Ok, quickly go and apply it to your project, then forget it for ever.

This was the worst case! What if you found a solution that no one will be able to find and what if there are many people curious about the solution of your question? Here, you are the hero and you should share your solution with others. You can be sure that your answer to your own question will be up-voted if it’s really an important solution.

Stackoverflow is not Google

If you want to get an answer to your question, first you should have a real question! Following examples show us they are not real questions :

How to delete text file content in libgdx?
I am new in libgdx framework,so plese help me.

You should first read the documentation of the libgdx framework.

I want to develop a card game, is unity enough to do that?

Unity is enough to make any type of game, are you enough to develop ?

Are these libraries enough to develop an android application?
Otto-bus, Glide, dagger, mockito.

Oh yes, what is your next question?

Please don’t think with your fingers! Firstly you should make an investigation on the web and need to be familiar that you wondering about. Then it’s reasonable to ask a question on stackoverflow.

What did you try so far?

Please show your initial effort before asking a question about implementation of an algorithm. Show your code completely of partially if possible. At least, show some pseudo code.

Is it possible to implement Beier-neely algorithm using java? 
Can you please show me some code?

Answer should be this:

Yes, it is possible.
import java.util.*;

Where is your log?

I see some questions doesn’t include any crash logs, stack traces, signal info or any information about the issue, exception. How can we know what is your problem without looking to any logs? It is true that software developers have some special forces but you can be sure about they are not psychic or telepath. You should show some error logs about the problem you are facing.

I think stackoverflow will be a better place if we all can be careful while using it.

Balian d’Ibelin says :

"Nemo vir est qui mundum non reddat meliorem"

Translation :

What man is a man who does not make the stackoverflow better?

:)