2011. 4. 14. 17:46

getBaseContext().getString(R.string.xxx)

'안드로이드 > 잔지식' 카테고리의 다른 글

adb shell에서 직접 app실행시키기  (0) 2012.02.10
나인패치  (0) 2011.05.05
한글 bold효과넣기  (0) 2011.04.06
singleinstance 는 startActivityForResult 사용불가  (0) 2011.04.04
Posted by newkie
2011. 4. 12. 11:09


JSONObject jObject = new JSONObject();
JSONArray jArray = new JSONArray();//배열이 필요할때

for (i=0;i>10;i++)//배열
  {
    JSONObject sObject = new JSONObject();//배열 내에 들어갈 json
    try
    {
      sObject.put("title","title");
      sObject.put("count", i);
      jArray.put(sObject);
    }
    catch (JSONException e)
    {
      log("Data json err : " + e.getMessage());
    }
}
try
{
  jObject.put("id", "newkie");
  jObject.put("datas", jArray);//배열을 넣음
}
catch (JSONException e)
{
  log("Data json err : " + e.getMessage());
}
jstring = jObject.toString();



이런식으로 하면 jstring이 {"id":"newkie","datas":[{"title":"title","count":0}.....]} 이렇게 나옴



이걸 다시 파싱



try
  {
   //받은데이터 파싱
   jObject = new JSONObject(jstring);
   
   id = jObject.getString("id");
   Log.d("id", id);
   
   JSONArray datas = jObject.getJSONArray("datas");
   int size = datas.length();
   Log.i("size", String.valueOf(size));
   
   for(int i=0; i<size; i++)
   {
    
    title = datas.getJSONObject(i).getString("title");
    Log.d("title", title);
    
    count = datas.getJSONObject(i).getString("count");
    Log.d("count", count);
    
    Title p = new Title(title,count);//지정해둔 getClass

    titlelist.add(p);리스트에 추가
       
   }
  }
  catch (Exception e)
  {
   e.getMessage()
  }


대충 이런식.

'자바' 카테고리의 다른 글

돈에 ,찍기나 전화번호에 -찍는 등의 정규식.  (0) 2011.04.21
배열정렬 Comparator  (1) 2011.03.31
간단한 쓰레드 예제  (0) 2011.03.11
암호화/복호화  (0) 2011.03.11
Posted by newkie
2011. 4. 6. 17:08

tt.setPaintFlags(tt.getPaintFlags() | Paint.FAKE_BOLD_TEXT_FLAG);

'안드로이드 > 잔지식' 카테고리의 다른 글

adb shell에서 직접 app실행시키기  (0) 2012.02.10
나인패치  (0) 2011.05.05
코드에서 R.string 사용  (0) 2011.04.14
singleinstance 는 startActivityForResult 사용불가  (0) 2011.04.04
Posted by newkie
2011. 4. 6. 13:51
0이면 전환없이 바로 보여줌

public void onResume()
 {
  overridePendingTransition(0, 0);
  super.onResume();
 }

0을 딴걸로 바꿀수 있으니 찾아봐도 됨(fade, push_right_in 등등)
Posted by newkie
2011. 4. 4. 18:03

은 냉무

'안드로이드 > 잔지식' 카테고리의 다른 글

adb shell에서 직접 app실행시키기  (0) 2012.02.10
나인패치  (0) 2011.05.05
코드에서 R.string 사용  (0) 2011.04.14
한글 bold효과넣기  (0) 2011.04.06
Posted by newkie
2011. 4. 4. 15:33
h ttp://www.google.com/ig/api?hl=ko&weather=,,,"+위도+","+경도


XML로 오는걸 파싱하면 됨
Posted by newkie
2011. 4. 1. 17:13

import android.os.Vibrator;

Vibrator Vibe = (Vibrator)context.getSystemService( context.VIBRATOR_SERVICE );
Vibe.vibrate(1000);
Posted by newkie
2011. 3. 31. 10:21

class timeComparator implements Comparator {
       public int compare(Object o1, Object o2) {
         String en1 = ((A)o1).d;
         String en2 = ((A)o2).d;
         return en1.compareTo(en2); // ascending 정렬
       }
    }

하고 정렬할 리스트에 아래 문장을 넣어줌

Collections.sort(list, new timeComparator());

'자바' 카테고리의 다른 글

돈에 ,찍기나 전화번호에 -찍는 등의 정규식.  (0) 2011.04.21
JSON 배열 만들고 파싱하기  (2) 2011.04.12
간단한 쓰레드 예제  (0) 2011.03.11
암호화/복호화  (0) 2011.03.11
Posted by newkie
2011. 3. 29. 09:00
private ProgressDialog mProgressDialog = null;

private Handler handler = new Handler();



...
mainProcessing();
...



    private void mainProcessing() 
    {
     // 시간이 많이 드는 작업을 자식 스레드로 옮긴다.
     Thread thread = new Thread(null, doBackgroundThreadProcessing, "Background");
     thread.start();
    }
    
    // 백그라운드 처리 메서드를 실행하는 Runnable.
    private Runnable doBackgroundThreadProcessing = new Runnable()
    {
     public void run()
     {
     backgroundThreadProcessing();
     }
    };
    
    // 백그라운드에서 몇 가지 처리를 수행하는 메서드.
    private void backgroundThreadProcessing()
    {    
     Log.d("Thread Start", "Thread Start~!");

     try 
     {
    //+
   // [...시간 소모적인 작업들...]
   //-
         
            handler.post(doUpdateGUI);
     }
     catch (Exception ex)
     {
     ex.toString();
     }
    }
    
    // GUI 업데이트 메서드를 실행하는 Runnable.
    public Runnable doUpdateGUI = new Runnable()
    {
     public void run()
     {
     updateGUI();
     }
    };
    
    public void updateGUI()
    {
     // [...다이얼로그를 오픈하거나 GUI 요소를 수정할 수 있다...]
    }
Posted by newkie
2011. 3. 24. 17:14

ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> list = am.getRunningAppProcesses();
for(RunningAppProcessInfo rapi : list)
{
Log.i("proclist", "runningProcessName : " + rapi.processName + ", importance : " + rapi.importance);
}

//importance는 해당 프로세스가 FOREGROUND, BACKGROUND 또는 SERVICE로 구동중인지 알 수 있다.
//RunningAppProcessInfo.IMPORTANCE_FOREGROUND (100)
//RunningAppProcessInfo.IMPORTANCE_SERVICE (300)
//RunningAppProcessInfo.IMPORTANCE_BACKGROUND (400)
Posted by newkie