Integrate Jira with Android

If you want integrate jira in your android proyect you will download a library which is JMC(Jira Mobile Connect).

you donwload here and import project in you workspace.

Then in your android proyect
properties -> android
add JMC library.

I had to edit AndroidManifest.xml file and add the following between the tags:

<service android:name="com.atlassian.jconnect.droid.service.RemoteFeedbackService" />

I had to add some configuration strings for Jira Mobile Connect to be able to know which project and server url to post crash reports and/or feedback to. The server url is the url of the server to where your Jira instance is hosted. The api key is obtained from your install of Jira and the project name is the name of the project. The file that I add this to is /res/values/strings.xml:

<!-- JIRA connect settings -->

<string name="jconnect.droid.config.server_url">http://your-url.com:8080/</string>
<string name="jconnect.droid.config.project">FA</string>
<string name="jconnect.droid.config.api_key">KEY_XXXXXXXXXXX</string>

<string name="crash_notification.title">JMC Sample App Crashed</string>
    <string name="crash_notification.text">Click to send a crash report.</string>
    <string name="crash_notification.dialog_text">The sample app has crashed. Please click okay to send back the data to the developers. (You are awesome btw; just putting it out there.)</string>
    <string name="crash_notification.dialog_request_user_email">Your email address:</string>

You should replace ‘KEY_XXXXXXXXXXX’ with your key and you should replace ‘http://http://your-url.com:8080/’ with your url. You can find your key within Jira at Administration/Projects//Summary/Settings.

Now you create a class that extends application

package com.thedeveloperworldisyours.integratejiraandroid;

import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import android.app.Application;
import com.atlassian.jconnect.droid.Api;
@ReportsCrashes(
        formKey = "",
        mode = ReportingInteractionMode.NOTIFICATION,
        resDialogEmailPrompt = R.string.crash_notification_dialog_request_user_email,
        resNotifTickerText = R.string.crash_notification_title,
        resNotifTitle = R.string.crash_notification_title,
        resNotifText = R.string.crash_notification_text,
        resDialogText = R.string.crash_notification_dialog_text)
public class MyApplication extends Application{
	 public void onCreate() {
		 Api.init( this );
	        super.onCreate();
	    }
}

Also you had to edit AndroidManifest.xml and add the Internet permission and the name of application.

<uses-permission android:name="android.permission.INTERNET"/>
<application


 android:name="MyApplication" >

If all that you want is crash logging, you can stop here because the call to App.init causes the crash reporting to work.

Next, if you want to send feedback you will create a activity.
Your activity has a button which send feedback.

In your activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".TheDeveloperWorldIsYoursActivity" >

    <TextView
        android:id="@+id/textViewTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
    <Button android:id="@+id/buttonFeedback"
        android:layout_below="@+id/textViewTitle" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/feedback"/>

</RelativeLayout>

Now you Activity.class this code

package com.thedeveloperworldisyours.integratejiraandroid;

import com.atlassian.jconnect.droid.Api;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class TheDeveloperWorldIsYoursActivity extends Activity {

	private Button feedbackButton;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_the_developer_world_is_yours);
		feedbackButton = (Button) findViewById(R.id.buttonFeedback);
		feedbackButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(Api.createFeedbackIntent(TheDeveloperWorldIsYoursActivity.this));
			}
		});
		
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *