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.pm.PackageInfo;

import android.util.Log;

public class Main {
    public static int buildRev = 0;
    public static boolean fullVersionInfo = false;

    public static String formatVersion(Context context, int i) {
        int j = 0xff & i >> 8;
        String s;
        int k;
        if (j == 0)
            s = (new StringBuilder()).append(0xf & i >> 24).append(".").append(0xff & i >> 16).toString();
        else
            s = (new StringBuilder()).append(0xf & i >> 24).append(".").append(0xff & i >> 16).append(".").append(j)
                    .toString();
        Log.d("MicroMsg.SDK.ChannelUtil", (new StringBuilder("minminor ")).append(j).toString());
        k = 0xfffffff & i;
        if (context != null)
            try {
                PackageInfo packageinfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 128);
                if (packageinfo != null) {
                    k = packageinfo.versionCode;
                    s = packageinfo.versionName;
                }
            } catch (Exception exception) {
                exception.printStackTrace();
            }
        if (fullVersionInfo) {
            s = (new StringBuilder()).append(s).append(" r").append(k).append("(build.").append(buildRev)
                    .append(")").toString();
            Log.d("MicroMsg.SDK.ChannelUtil", (new StringBuilder("full version: ")).append(s).toString());
        }
        return s;
    }
}