Skip to content

Instantly share code, notes, and snippets.

@burnix
Created August 3, 2015 15:25
Show Gist options
  • Save burnix/ee88895c2860191e2f34 to your computer and use it in GitHub Desktop.
Save burnix/ee88895c2860191e2f34 to your computer and use it in GitHub Desktop.
package com.igor.cars;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import static com.igor.cars.Cars.car_type.coupe;
import static java.lang.String.valueOf;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
th();
}
public void th(){
try {
PackageManager packageManager = getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo("com.test.tesk1", 0);
String versionName = packageInfo.versionName;
System.out.println(versionName);
} catch (PackageManager.NameNotFoundException e){
System.out.println("Vladik molotets " + e);
} catch (NullPointerException e ){
System.out.println("NPE" + e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment