Created
August 3, 2015 15:25
-
-
Save burnix/ee88895c2860191e2f34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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