posted by 네코냥이 2014. 7. 30. 14:24


부팅 리시버.pdf


posted by 네코냥이 2014. 7. 29. 16:14
ServiceState objServiceState = new ServiceState();
boolean bServiceStateRoaming = objServiceState.getRoaming();

로밍 단말이 없어서 아직 테스트 해보진 못함


posted by 네코냥이 2014. 7. 28. 16:00



Turning ON or OFF airplane mode programmatically in Android _ yogeshblogspot.pdf



==================================================================================


private Boolean isAirModeOn() {

Boolean bol;

if(Build.VERSION.SDK_INT<17){

bol = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1;

}else{

bol = Settings.System.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 1;

}

return bol;

}


==================================================================================



posted by 네코냥이 2014. 7. 21. 10:28


안드로이드 메뉴.pdf



@Override
public boolean onOptionsItemSelected(MenuItem item) {
   
// Handle item selection
   
switch (item.getItemId()) {
       
case R.id.new_game:
            newGame
();
           
return true;
       
case R.id.help:
            showHelp
();
           
return true;
       
default:
           
return super.onOptionsItemSelected(item);
   
}
}


posted by 네코냥이 2014. 7. 15. 15:33


버전가져오기


You can get it by calling Build.VERSION.SDK.

From 1.6 on, you should use Build.VERSION.SDK_INT instead
because Build.VERSION.SDK is deprecated.

http://stackoverflow.com/questions/3506792/android-api-version-programmatically





매칭 시키기


Code Name             Version      Api level

(no code name)         1.0          API level 1

(no code name)         1.1          API level 2

Cupcake                1.5          API level 3, NDK 1

Donut                  1.6          API level 4, NDK 2

Eclair                 2.0          API level 5

Eclair                 2.0.1        API level 6

Eclair                 2.1          API level 7, NDK 3

Froyo                  2.2.x        API level 8, NDK 4

Gingerbread         2.3 - 2.3.2     API level 9, NDK 5

Gingerbread         2.3.3 - 2.3.7   API level 10

Honeycomb              3.0          API level 11

Honeycomb              3.1          API level 12, NDK 6

Honeycomb             3.2.x         API level 13

Ice Cream Sandwich 4.0.1 - 4.0.2    API level 14, NDK 7

Ice Cream Sandwich 4.0.3 - 4.0.4    API level 15, NDK 8

Jelly Bean           4.1.x          API level 16

Jelly Bean           4.2.x          API level 17

Jelly Bean           4.3.x          API level 18

KitKat      4.4 - 4.4.2     API level 19


posted by 네코냥이 2014. 7. 15. 15:23

07-15 15:19:04.680: E/AndroidRuntime(9733): java.lang.NoSuchMethodError: android.view.ViewTreeObserver.removeOnGlobalLayoutListener





There are two methods in ViewTreeObserver with almost the same name.

removeOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener victim)

(on then global) is a method that was added in API 16. It replaces

removeGlobalOnLayoutListener(ViewTreeObserver.OnGlobalLayoutListener victim)

(global then on) which has existed since API 1, but which is now deprecated. Compatibility libraries can cause confusion about these two methods; it can appear present at compile-time but fail subsequently.

This code thwarts the error:

try {
    thing.removeOnGlobalLayoutListener(victim);
} catch (NoSuchMethodError x) {
    thing.removeGlobalOnLayoutListener(victim);
}

So does this code:

if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
    thing.removeGlobalOnLayoutListener(victim);
} else {
    thing.removeOnGlobalLayoutListener(victim);
}





android - Why does removeOnGlobalLayoutListener throw a NoSuchMethodError_ - Stack Overflow.pdf


posted by 네코냥이 2014. 7. 10. 10:59

Unit of measurement of TextView.setTextSize()

The Soundcorset metronome and tuner, in which I wrote it with Scaloid, is keep growing and hits 70,000 downloads. Until recently, it has a strange problem that it displays very large text for some devices, so that some button texts are clipped away out of the layout. After some code investigation, I found that it is very tricky pitfall because the code does not seems to have any problem at first:
STextView("Hello").textSize(20 sp)  // not correct!
The unit specification like 20 sp is very common in Scaloid. The implicit function sp converts the number from the sp unit to the pixel unit. The code above looks fine because the most of the Android API receives a size as the pixel unit. But there was a single exception. The methodTextView.setTextSize(float) does not receives a size as the pixel unit, it receives sp unit instead. It may cause a mistake because the most of other APIs handles a size as the pixel unit, even inTextView.getTextSize()!!! So I overridden STextView.textSize so that the APIs have consistency in pixel units:
@inline def textSize  (p: Int) =  textSize_=(p)
@inline def textSize_=(p: Int) = { 
  basis.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, p)
  basis 
}
Now we can safely use the method textSize with the implicit unit conversions:
STextView("Hello").textSize(20 sp)  // correct :-D
I patched the current snapshot, and it will be available at the next release of Scaloid.


posted by 네코냥이 2014. 7. 2. 17:55


android - Set two buttons to same width regardless of screen size_ - Stack Overflow.pdf


weight 속성은, 남은 width에서 가져온다.

그래서 뷰의 width=0으로 고정해줘야만, 길이가 균등분배된다.


아니면 해당 뷰들의 width가 동일해도 좋다.

posted by 네코냥이 2014. 7. 2. 17:54


android - findViewById within fragment - Stack Overflow.pdf


posted by 네코냥이 2014. 7. 1. 17:03

Context -> getResources();



int resID = getResources().getIdentifier("button_%i",
    "id", getPackageName());
View addButton = findViewById(resID);