2017년 9월 2일 토요일

그레들 버젼 정보 가져오기

[gradle version 정보 가져오기]
String versionCode = BuildConfig.VERSION_NAME;

text1.setText("幸運のMiniLoto番号 発生機"+versionCode);


[string xml 에서 가져오기]
String versionCode = BuildConfig.VERSION_NAME;
String app_name = getString(R.string.app_name);

proguard 설정

-optimizationpasses 5

#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames

#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses

#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify

#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose

#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class org.jsoup.** {
  public *;
 }




gradle

    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


layout

tools:shrinkMode="strict">


android network to check



  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ConnectivityManager manager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo mobile = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
        NetworkInfo wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        // wifi 또는 모바일 네트워크 어느 하나라도 연결이 되어있다면,
        if (wifi.isConnected() || mobile.isConnected()) {
            setContentView(R.layout.activity_main);

            Log.d(TAG,"dfdf");
            new miniloto().execute();

        } else {

            AlertDialog.Builder ad = new AlertDialog.Builder(MainActivity.this);
            {
                setContentView(R.layout.activity_main);
                Log.d(TAG,"afaf");


//                wtext4.setText("네트워크 통신 에러");
                ad.setTitle("Network Error!");
                ad.setMessage("Your Network is Somthing Wrong!!");
                ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                        wtext1.setText("Network Error!");
                        wtext2.setText("Please ON Wifi & ON Mobile Network");
                        wtext3.setText("");
                        wtext4.setText("");
                        wtext5.setText("");
                        wtext6.setText("If you To check your Miniloto Number ");


                       return;
                    }
                });
                Log.d(TAG,"afaf");
                ad.show();

            }
        }