Bucket Place/Android

[메모] android

Cloud Travel 2014. 10. 28. 13:25

-----  pixel <-> dpi -----

    public int dipToPixels(int dipValue) {

        DisplayMetrics metrics = getResources().getDisplayMetrics();

        return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics);

    }


    private int pixelToDpi(int pixel) {

        return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, pixel, getResources().getDisplayMetrics());

    }



------- 키보드 닫기 ----

[EditText].clearFocus();

            mNewScrapbookTitle.setText(""); 

InputMethodManager imm = (InputMethodManager)mContext.getSystemService(

      Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow([EditText].getWindowToken(), 0);




----- eclipse error : content loader 0% ------


\workspace\.metadata\.plugins\org.eclipse.core.resources\\.projects

1> Copy .projects folder and take backup for temporary.

2> Now Delete .projects folder from workspace directory. (you will not loose your proejcts)

3> Start Eclipse and wait for all progress ends at right/bottom corner. Once completed all processes, shutdown Eclipse.

4> Paste .projects folder which you have backup earlier to \workspace\.metadata\.plugins\org.eclipse.core.resources\ directory. Overwrite existing .projects folder.

5> Start Eclipse again. And all will work.



---- fragment onResume crash > restart apps ----

protected void onResume(){

super.onResume();

// crash handler

Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler(){

    public void uncaughtException(Thread thread, Throwable ex){

        Log.v(StaticVariables.TAG, "onUncaughtException triggered. Error:");

        ex.printStackTrace();

        //restart your app here like this

            Intent i = new Intent(getApplicationContext(), IntroActivity.class );

            getApplicationContext().startActivity(i);

        }

    });

}