//비트맵을 png로 저장해보자

public static void SavePng(FileOutputStream  out, Bitmap bitmap)

{

try

{       

bitmap.compress(CompressFormat.PNG, 100, out);

}

catch (Exception e) 

{

e.printStackTrace();

}

finally

{

try

{

out.close();

  }

  catch (IOException e)

  {

  e.printStackTrace();

  }

}

}

'ANDROID' 카테고리의 다른 글

android 치트 막기.  (0) 2014.10.11
웹으로 파일 업로드.  (0) 2014.10.11
인터넷 상태 확인 네트워크 상태.  (0) 2014.10.11
안드로이드 맥어드레스 얻어오기 macaddress  (0) 2014.10.11
루팅 체크.  (0) 2014.10.11
블로그 이미지

은호아빠

여행, 맛집, 일상, 프로그래밍, 개발자, 윈도우, 웹, jsp, spring, db, mysql, oracle, c#

,

public static boolean getIsNetworkState()

{

boolean result=false;

 ConnectivityManager cm = (ConnectivityManager) Global.mContext.getSystemService(Global.mContext.CONNECTIVITY_SERVICE);

 NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

 boolean isWifiAvail; 

 boolean isWifiConn;

 try {

 isWifiAvail = ni.isAvailable();

 isWifiConn = ni.isConnected();

} catch (Exception e) {

// TODO: handle exception

 isWifiAvail = false;

 isWifiConn = false;

}

 ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

 boolean isMobileAvail;

 boolean isMobileConn;

 try {

  isMobileAvail = ni.isAvailable();

  isMobileConn = ni.isConnected();

} catch (Exception e) {

// TODO: handle exception

  isMobileAvail = false;

  isMobileConn = false;

}

 String status = "WiFi\nAvail = " + isWifiAvail + "\nConn = "

   + isWifiConn + "\nMobile\nAvail = " + isMobileAvail

   + "\nConn = " + isMobileConn + "\n";

 Util.Log("네트워크 status : "+status);

 if(isWifiConn || isMobileConn)

 {

 result=true;

 }

 return result;

}

블로그 이미지

은호아빠

여행, 맛집, 일상, 프로그래밍, 개발자, 윈도우, 웹, jsp, spring, db, mysql, oracle, c#

,

public static String getMacAddress(Context context) {

 WifiManager wifiman = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);        

 WifiInfo wifiinfo = wifiman.getConnectionInfo();  


 String strMacAddress = "";

 if (wifiinfo.getMacAddress() != null)  {

   strMacAddress = wifiinfo.getMacAddress();

 }  

 return strMacAddress;

}

블로그 이미지

은호아빠

여행, 맛집, 일상, 프로그래밍, 개발자, 윈도우, 웹, jsp, spring, db, mysql, oracle, c#

,

루팅 체크.

ANDROID 2014. 10. 11. 13:36

루팅체크. 

public static boolean isRooting()

{

boolean isRootingFlag=false;

 String ROOT_PATH = Environment.

           getExternalStorageDirectory() + "";

   String ROOTING_PATH_1 = "/system/bin/su";

   String ROOTING_PATH_2 = "/system/xbin/su";

   String ROOTING_PATH_3 = "/system/app/SuperUser.apk";

   String ROOTING_PATH_4 = "/data/data/com.noshufou.android.su";

    

    String[] RootFilesPath = new String[]{

    ROOT_PATH + ROOTING_PATH_1 ,

           ROOT_PATH + ROOTING_PATH_2 , 

           ROOT_PATH + ROOTING_PATH_3 , 

           ROOT_PATH + ROOTING_PATH_4

   };

    try {

           Runtime.getRuntime().exec("su");

           isRootingFlag = true;

       } catch ( Exception e) {

           // Exception 나면 루팅 false;

           isRootingFlag = false;

       }

        

       if(!isRootingFlag){

           isRootingFlag = checkRootingFiles(createFiles(RootFilesPath));

       }

return isRootingFlag;

}

/**

     * 루팅파일 의심 Path를 가진 파일들을 생성 한다.

     */

    private static File[] createFiles(String[] sfiles){

        File[] rootingFiles = new File[sfiles.length];

        for(int i=0 ; i < sfiles.length; i++){

            rootingFiles[i] = new File(sfiles[i]);

        }

        return rootingFiles;

    }

     

    /**

     * 루팅파일 여부를 확인 한다.

     */

    private static boolean checkRootingFiles(File... file){

        boolean result = false;

        for(File f : file){

            if(f != null && f.exists() && f.isFile()){

                result = true;

                break;

            }else{

                result = false;

            }

        }

        return result;

    }

블로그 이미지

은호아빠

여행, 맛집, 일상, 프로그래밍, 개발자, 윈도우, 웹, jsp, spring, db, mysql, oracle, c#

,

한글만~

public boolean isHangl(String email) {

        if (email==null) return false;

        boolean b =email.matches(".*[ㄱ-ㅎㅏ-ㅣ가-힣]+.*");

        return b;

    }

블로그 이미지

은호아빠

여행, 맛집, 일상, 프로그래밍, 개발자, 윈도우, 웹, jsp, spring, db, mysql, oracle, c#

,

이메일 검사.

public boolean isEmail(String email) {

        if (email==null) return false;

        boolean b = Pattern.matches("[\\w\\~\\-\\.]+@[\\w\\~\\-]+(\\.[\\w\\~\\-]+)+",email.trim());        

        return b;

    }


블로그 이미지

은호아빠

여행, 맛집, 일상, 프로그래밍, 개발자, 윈도우, 웹, jsp, spring, db, mysql, oracle, c#

,
안드로이드 사용자 디스플레이 랭귀지 얻어오기. 

각회사 단말기별로 많이 테스트 해보지 못했음. 예외상황 발생시 조건 추가해서 사용하시기 바랍니다.


public boolean IsLanguageKorea()

{

boolean result=false;

String  is_language=Global.mContext.getResources().getConfiguration().locale.getDisplayLanguage(); //안드로이드 context를 가져와서 하세요.


if(is_language.equals("ko")|| is_language.equals("KO")|| is_language.equals("한국어"))

{

result=true;

}

return result;

}



블로그 이미지

은호아빠

여행, 맛집, 일상, 프로그래밍, 개발자, 윈도우, 웹, jsp, spring, db, mysql, oracle, c#

,