Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;
import android.content.Intent;

import android.content.pm.PackageManager.NameNotFoundException;

import android.net.Uri;

public class Main {
    public static void sendFeedback2(Context context) {

        String versionName = "";

        try {

            versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;

        } catch (NameNotFoundException e) {

            e.printStackTrace();
        }

        StringBuffer sb = new StringBuffer();
        sb.append("We would like to hear your feedback and improvement ideas. Please feel free to share below :")
                .append("\r\n").append("\r\n").append("\r\n").append("Attach Screenshots (if any) : ")
                .append("\r\n").append("\r\n").append("\r\n").append("Running on ").append(android.os.Build.MODEL)
                .append("\r\n").append("OS Version : ").append(android.os.Build.VERSION.RELEASE).append("\r\n")
                .append("Client Version : ").append(versionName);

        Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "messageplus_feedback@starhub.com", null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Message+ - Feedback");
        emailIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
        context.startActivity(Intent.createChooser(emailIntent, "Choose email client"));

    }
}