File tree Expand file tree Collapse file tree
java/org/buildmlearn/toolkit/activity Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .buildmlearn .toolkit .activity ;
22
3+ import android .content .pm .PackageInfo ;
4+ import android .content .pm .PackageManager ;
35import android .os .Bundle ;
46import android .support .v7 .app .AppCompatActivity ;
57import android .support .v7 .widget .Toolbar ;
68import android .view .Menu ;
79import android .view .MenuItem ;
10+ import android .widget .TextView ;
811
912import org .buildmlearn .toolkit .R ;
1013
@@ -24,6 +27,17 @@ protected void onCreate(Bundle savedInstanceState) {
2427 setSupportActionBar ((Toolbar ) findViewById (R .id .toolbar ));
2528 getSupportActionBar ().setDisplayHomeAsUpEnabled (true );
2629
30+ PackageInfo pInfo = null ;
31+ try {
32+ pInfo = getPackageManager ().getPackageInfo (getPackageName (), 0 );
33+ String version = pInfo .versionName ;
34+ ((TextView )findViewById (R .id .app_version )).setText ("Version: " + version );
35+ } catch (PackageManager .NameNotFoundException e ) {
36+ ((TextView )findViewById (R .id .app_version )).setText ("Version: 1.0" );
37+ e .printStackTrace ();
38+ }
39+
40+
2741
2842 }
2943
Original file line number Diff line number Diff line change 5656 android : text =" @string/main_subtitle"
5757 android : textColor =" @color/black_secondary_text"
5858 android : textSize =" @dimen/title" />
59+
60+ <TextView
61+ android : id =" @+id/app_version"
62+ android : layout_width =" match_parent"
63+ android : layout_height =" wrap_content"
64+ android : textColor =" @color/black_secondary_text"
65+ android : textSize =" @dimen/caption" />
5966 </LinearLayout >
6067
6168 </LinearLayout >
You can’t perform that action at this time.
0 commit comments