'프로그래밍/Android'에 해당되는 글 13건

  1. 2011.06.13 :: ColorPickerDialog
  2. 2011.06.13 :: SQLlite ALTER TABLE
  3. 2011.06.07 :: android DB ALTER
  4. 2011.06.07 :: GPS
  5. 2011.06.07 :: 증강현실
  6. 2011.06.07 :: compass
  7. 2011.06.07 :: Location
  8. 2011.06.07 :: 카메라
  9. 2011.05.30 :: Android <Activity - android:launchMode>
  10. 2011.05.30 :: Android Intent flag
프로그래밍/Android 2011.06.13 11:47

public class ColorPickerDialog extends Dialog {
    private static int CENTER_X = 100;
    private static int CENTER_Y = 100;
    private static int CENTER_RADIUS = 32;

    public interface OnColorChangedListener {
        void colorChanged(int color);
    }

    private OnColorChangedListener mListener;
    private int mInitialColor;

    private class ColorPickerView extends View {
        private Paint mPaint;
        private Paint mCenterPaint;
        private final int[] mColors;
        private OnColorChangedListener mListener;
        
        ColorPickerView(Context c, OnColorChangedListener l, int color) {
            super(c);
            mListener = l;
            mColors = new int[] {
                0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
                0xFFFFFF00, 0xFFFFFFFF, 0xFF808080, 0xFF000000, 0xFFFF0000
            };
            Shader s = new SweepGradient(0, 0, mColors, null);
            
            mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
            mPaint.setShader(s);
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setStrokeWidth(CENTER_RADIUS);
            
            mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
            mCenterPaint.setColor(color);
            mCenterPaint.setStrokeWidth(5);
        }
        
        private boolean mTrackingCenter;
        private boolean mHighlightCenter;

        @Override 
        protected void onDraw(Canvas canvas) {
            float r = CENTER_X - mPaint.getStrokeWidth()*0.8f;
            
            canvas.translate(CENTER_X, CENTER_X);
            
            canvas.drawOval(new RectF(-r, -r, r, r), mPaint);            
            canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);
            
            if (mTrackingCenter) {
                int c = mCenterPaint.getColor();
                mCenterPaint.setStyle(Paint.Style.STROKE);
                
                if (mHighlightCenter) {
                    mCenterPaint.setAlpha(0xFF);
                } else {
                    mCenterPaint.setAlpha(0x80);
                }
                canvas.drawCircle(0, 0,
                                  CENTER_RADIUS + mCenterPaint.getStrokeWidth(),
                                  mCenterPaint);
                
                mCenterPaint.setStyle(Paint.Style.FILL);
                mCenterPaint.setColor(c);
            }
        }
        
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            setMeasuredDimension(CENTER_X*2, CENTER_Y*2);
        }

        public void setCenterColor(int color) {
            mCenterPaint.setColor(color);
            invalidate();
        }
        
        public void setTransparency(int alpha) {
            int color = mCenterPaint.getColor();            
            int newColor = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
            mCenterPaint.setColor(newColor);
            mEditText.setText(convertToARGB(newColor));
            invalidate();
        }
        
        private int ave(int s, int d, float p) {
            return s + java.lang.Math.round(p * (d - s));
        }
        
        private int interpColor(int colors[], float unit) {
            if (unit <= 0) {
                return colors[0];
            }
            if (unit >= 1) {
                return colors[colors.length - 1];
            }
            
            float p = unit * (colors.length - 1);
            int i = (int)p;
            p -= i;

            // now p is just the fractional part [0...1) and i is the index
            int c0 = colors[i];
            int c1 = colors[i+1];
            int a = ave(Color.alpha(c0), Color.alpha(c1), p);
            int r = ave(Color.red(c0), Color.red(c1), p);
            int g = ave(Color.green(c0), Color.green(c1), p);
            int b = ave(Color.blue(c0), Color.blue(c1), p);
            
            return Color.argb(a, r, g, b);
        }
               
        private static final float PI = 3.1415926f;

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            float x = event.getX() - CENTER_X;
            float y = event.getY() - CENTER_Y;
            boolean inCenter = java.lang.Math.sqrt(x*x + y*y) <= CENTER_RADIUS;
            
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    mTrackingCenter = inCenter;
                    if (inCenter) {
                        mHighlightCenter = true;
                        invalidate();
                        break;
                    }
                case MotionEvent.ACTION_MOVE:
                    if (mTrackingCenter) {
                        if (mHighlightCenter != inCenter) {
                            mHighlightCenter = inCenter;
                            invalidate();
                        }
                    } else {
                        float angle = (float)java.lang.Math.atan2(y, x);
                        // need to turn angle [-PI ... PI] into unit [0....1]
                        float unit = angle/(2*PI);
                        if (unit < 0) {
                            unit += 1;
                        }
                        int color = interpColor(mColors, unit);
                        mCenterPaint.setColor(color);
                        mEditText.setText(convertToARGB(color));
                        invalidate();
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    if (mTrackingCenter) {
                        if (inCenter) {
                            mListener.colorChanged(mCenterPaint.getColor());
                        }
                        mTrackingCenter = false;    // so we draw w/o halo
                        invalidate();
                    }
                    break;
            }
            return true;
        }
    }
    
    private String convertToARGB(int color) {
        String alpha = Integer.toHexString(Color.alpha(color));
        String red = Integer.toHexString(Color.red(color));
        String green = Integer.toHexString(Color.green(color));
        String blue = Integer.toHexString(Color.blue(color));        
        
        if (alpha.length() == 1) {
            alpha = "0" + alpha;
        }
        
        if (red.length() == 1) {
            red = "0" + red;
        }
        
        if (green.length() == 1) {
            green = "0" + green;
        }
        
        if (blue.length() == 1) {
            blue = "0" + blue;
        }
        
        return "#" + alpha + red + green + blue;
    }
    
    private int convertToColorInt(String argb) throws NumberFormatException {       
        
        int alpha = -1, red = -1, green = -1, blue = -1;
            
        if (argb.length() == 8) {
            alpha = Integer.parseInt(argb.substring(0, 2), 16);
            red = Integer.parseInt(argb.substring(2, 4), 16);
            green = Integer.parseInt(argb.substring(4, 6), 16);
            blue = Integer.parseInt(argb.substring(6, 8), 16);
        }
        else if (argb.length() == 6) {
            alpha = 255;
            red = Integer.parseInt(argb.substring(0, 2), 16);
            green = Integer.parseInt(argb.substring(2, 4), 16);
            blue = Integer.parseInt(argb.substring(4, 6), 16);
        }
        
        return Color.argb(alpha, red, green, blue);        
    }
    
    private Context mContext;
    private EditText mEditText;
    private ColorPickerView mColorPickerView;
    private SeekBar mTransparencyBar;

    public ColorPickerDialog11(Context context, OnColorChangedListener listener, int initialColor) {
        super(context);
        mContext = context;
        mListener = listener;
        mInitialColor = initialColor;
       // CENTER_Y=CENTER_X=context.getResources().getDimensionPixelSize(R.dimen.color_picker_center);
       // CENTER_RADIUS=context.getResources().getDimensionPixelSize(R.dimen.color_picker_radius);
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        LinearLayout layout = new LinearLayout(mContext);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.setGravity(android.view.Gravity.CENTER); 
        
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                                                    LinearLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(10, 0, 10, 5);
        
        TextView tv = new TextView(mContext);
        //tv.setText(mContext.getString(R.string.pref_dialog_message_color_picker));
        layout.addView(tv, layoutParams);
        
        mColorPickerView = new ColorPickerView(getContext(), onColorChangedListener, mInitialColor);        
        layout.addView(mColorPickerView, layoutParams);
        
        mTransparencyBar = new SeekBar(mContext);
        mTransparencyBar.setMax(255);
//mTransparencyBar.setProgressDrawable(new TextSeekBarDrawable(mContext.getResources(), mContext.getString(R.string.pref_dialog_color_picker_alpha), true));
mTransparencyBar.setProgress(Color.alpha(mInitialColor));
mTransparencyBar.setOnSeekBarChangeListener(onTransparencyChangedListener);
layout.addView(mTransparencyBar, layoutParams);
        
        mEditText = new EditText(mContext);
        mEditText.addTextChangedListener(mEditTextListener);
        mEditText.setText(convertToARGB(mInitialColor));
        layout.addView(mEditText, layoutParams);

        setContentView(layout);
        setTitle(" 글자색 변경!!");
    }
    
    private OnColorChangedListener onColorChangedListener = new OnColorChangedListener() {
        public void colorChanged(int color) {
           mListener.colorChanged(color);
           dismiss();
        }
    };
    
    private SeekBar.OnSeekBarChangeListener onTransparencyChangedListener = new SeekBar.OnSeekBarChangeListener() {
        
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mColorPickerView.setTransparency(progress);
        }
        
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    };
    
    private TextWatcher mEditTextListener = new TextWatcher() {
        
        public void afterTextChanged(Editable s) {
        }
        
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
        
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            try {
                String s2 = (s.toString()).replace("#", "");
                if (s2.length() == 6 || s2.length() == 8) {
                    int color = convertToColorInt(s2);
                    mColorPickerView.setCenterColor(color);
                    mTransparencyBar.setProgress(Color.alpha(color));
                }            
            }
            catch (NumberFormatException e) {
            }
        } 
    };
    
    //Source: http://www.anddev.org/announce_color_picker_dialog-t10771.html
static final int[] STATE_FOCUSED = {android.R.attr.state_focused};
static final int[] STATE_PRESSED = {android.R.attr.state_pressed};
    
    static class TextSeekBarDrawable extends Drawable implements Runnable {
private static final long DELAY = 50;
private String mText;
private Drawable mProgress;
private Paint mPaint;
private Paint mOutlinePaint;
private float mTextWidth;
private boolean mActive;
private float mTextXScale;
private int mDelta;
private ScrollAnimation mAnimation;

public TextSeekBarDrawable(Resources res, String label, boolean labelOnRight) {
mText = label;
mProgress = res.getDrawable(android.R.drawable.progress_horizontal);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
mPaint.setTextSize(16);
mPaint.setColor(0xff000000);
mOutlinePaint = new Paint(mPaint);
mOutlinePaint.setStyle(Style.STROKE);
mOutlinePaint.setStrokeWidth(3);
mOutlinePaint.setColor(0xbbffc300);
mOutlinePaint.setMaskFilter(new BlurMaskFilter(1, Blur.NORMAL));
mTextWidth = mOutlinePaint.measureText(mText);
mTextXScale = labelOnRight? 1 : 0;
mAnimation = new ScrollAnimation();
}

@Override
protected void onBoundsChange(Rect bounds) {
mProgress.setBounds(bounds);
}
@Override
protected boolean onStateChange(int[] state) {
mActive = StateSet.stateSetMatches(STATE_FOCUSED, state) | StateSet.stateSetMatches(STATE_PRESSED, state);
invalidateSelf();
return false;
}
@Override
public boolean isStateful() {
return true;
}
@Override
protected boolean onLevelChange(int level) {
// Log.d(TAG, "onLevelChange " + level);
if (level < 4000 && mDelta <= 0) {
// Log.d(TAG, "onLevelChange scheduleSelf ++");
mDelta = 1;
mAnimation.startScrolling(mTextXScale, 1);
scheduleSelf(this, SystemClock.uptimeMillis() + DELAY);
} else
if (level > 6000 && mDelta >= 0) {
// Log.d(TAG, "onLevelChange scheduleSelf --");
mDelta = -1;
mAnimation.startScrolling(mTextXScale, 0);
scheduleSelf(this, SystemClock.uptimeMillis() + DELAY);
}
return mProgress.setLevel(level);
}
@Override
public void draw(Canvas canvas) {
mProgress.draw(canvas);

if (mAnimation.hasStarted() && !mAnimation.hasEnded()) {
// pending animation
mAnimation.getTransformation(AnimationUtils.currentAnimationTimeMillis(), null);
mTextXScale = mAnimation.getCurrent();
// Log.d(TAG, "draw " + mTextX + " " + SystemClock.uptimeMillis());
}
Rect bounds = getBounds();
float x = 6 + mTextXScale * (bounds.width() - mTextWidth - 6 - 6);
float y = (bounds.height() + mPaint.getTextSize()) / 2;
mOutlinePaint.setAlpha(mActive? 255 : 255 / 2);
mPaint.setAlpha(mActive? 255 : 255 / 2);
canvas.drawText(mText, x, y, mOutlinePaint);
canvas.drawText(mText, x, y, mPaint);
}

@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}

@Override
public void setAlpha(int alpha) {
}

@Override
public void setColorFilter(ColorFilter cf) {
}

public void run() {
mAnimation.getTransformation(AnimationUtils.currentAnimationTimeMillis(), null);
// close interpolation of mTextX
mTextXScale = mAnimation.getCurrent();
if (!mAnimation.hasEnded()) {
scheduleSelf(this, SystemClock.uptimeMillis() + DELAY);
}
invalidateSelf();
// Log.d(TAG, "run " + mTextX + " " + SystemClock.uptimeMillis());
}
}
static class ScrollAnimation extends Animation {
private static final long DURATION = 750;
private float mFrom;
private float mTo;
private float mCurrent;
public ScrollAnimation() {
setDuration(DURATION);
setInterpolator(new DecelerateInterpolator());
}
public void startScrolling(float from, float to) {
mFrom = from;
mTo = to;
startNow();
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
mCurrent = mFrom + (mTo - mFrom) * interpolatedTime;
// Log.d(TAG, "applyTransformation " + mCurrent);
}
public float getCurrent() {
return mCurrent;
}
}
}

'프로그래밍 > Android' 카테고리의 다른 글

ColorPickerDialog  (0) 2011.06.13
SQLlite ALTER TABLE  (0) 2011.06.13
android DB ALTER  (0) 2011.06.07
GPS  (0) 2011.06.07
증강현실  (0) 2011.06.07
compass  (0) 2011.06.07
posted by zerowns
프로그래밍/Android 2011.06.13 11:43

 @Override
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  if (oldVersion >= newVersion)
   return;
  String sql = null;
  if (oldVersion == 1) 
   sql = "alter table " + TABLE + " add note text;"; //추가
  if (oldVersion == 2)
   sql = "alter table " + TABLE + " DROP note text;";//삭제
  if (sql != null)
   db.execSQL(sql);
 }
}

'프로그래밍 > Android' 카테고리의 다른 글

ColorPickerDialog  (0) 2011.06.13
SQLlite ALTER TABLE  (0) 2011.06.13
android DB ALTER  (0) 2011.06.07
GPS  (0) 2011.06.07
증강현실  (0) 2011.06.07
compass  (0) 2011.06.07
posted by zerowns
프로그래밍/Android 2011.06.07 18:37

그냥 업그레이드 진행 하다가  DB날려먹고 눈물을 머금고 ㅡㅜ
실수 하지말자!

문제의 코드

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE_NAME);
onCreate(db);
}

public abstract void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion)

Since: API Level 1

Called when the database needs to be upgraded. The implementation should use this method to drop tables, add tables, or do anything else it needs to upgrade to the new schema version.

The SQLite ALTER TABLE documentation can be found here. If you add new columns you can use ALTER TABLE to insert them into a live table. If you rename or remove columns you can use ALTER TABLE to rename the old table, then create the new table and then populate the new table with the contents of the old table.

Parameters
dbThe database.
oldVersionThe old database version.
newVersionThe new database version.

'프로그래밍 > Android' 카테고리의 다른 글

ColorPickerDialog  (0) 2011.06.13
SQLlite ALTER TABLE  (0) 2011.06.13
android DB ALTER  (0) 2011.06.07
GPS  (0) 2011.06.07
증강현실  (0) 2011.06.07
compass  (0) 2011.06.07
posted by zerowns
프로그래밍/Android 2011.06.07 09:38

GPS



안드로이드 개발 중 어려운 부분인 위치정보 처리방법과 AR(증강현실) 구현방법에 대한 강의
(GPS신호를 못잡는 실내나 지하에서 AP 등을 이용해 위치정보를 획득하는 방법)

박유태 라람인터렉티브 연구원 

'프로그래밍 > Android' 카테고리의 다른 글

SQLlite ALTER TABLE  (0) 2011.06.13
android DB ALTER  (0) 2011.06.07
GPS  (0) 2011.06.07
증강현실  (0) 2011.06.07
compass  (0) 2011.06.07
Location  (0) 2011.06.07
posted by zerowns
프로그래밍/Android 2011.06.07 09:32
•NyARToolkit
•AndAR
•mixare

'프로그래밍 > Android' 카테고리의 다른 글

android DB ALTER  (0) 2011.06.07
GPS  (0) 2011.06.07
증강현실  (0) 2011.06.07
compass  (0) 2011.06.07
Location  (0) 2011.06.07
카메라  (0) 2011.06.07
posted by zerowns
프로그래밍/Android 2011.06.07 09:29
sensorMan= (SensorManager)ctx.getSystemService(Context.SENSOR_SERVICE);
sensorMan.registerListener(this, sensorMan.getDefaultSensor
(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST);
sensorMan.registerListener(this,sensorMan.getDefaultSensor
(Sensor.TYPE_ACCELEROMETER),SensorManager.SENSOR_DELAY_FASTEST);

        public static volatile float direction= (float) 0;
        public static volatile floatinclination;
        public static volatile floatrollingZ= (float)0;
        public static volatile floatkFilteringFactor= (float)0.05;
        public static float aboveOrBelow= (float)0;
        public void onAccuracyChanged(Sensor arg0, intarg1){}
        
        publicvoidonSensorChanged(SensorEventevt)
        {
       floatvals[] = evt.values;
       if(evt.sensor.getType() == Sensor.TYPE_ORIENTATION)
       {
       floatrawDirection= vals[0];
       direction=(float) ((rawDirection* kFilteringFactor) +
       (direction* (1.0 -kFilteringFactor)));
       inclination= (float) ((vals[2] * kFilteringFactor) + 
        (inclination* (1.0 -kFilteringFactor))); 
       if(aboveOrBelow> 0)inclination= inclination* -1;
       if(evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER){
        aboveOrBelow=(float) ((vals[2] * kFilteringFactor) + (aboveOrBelow* (1.0 -kFilteringFactor)));
       }
   }
   }

'프로그래밍 > Android' 카테고리의 다른 글

GPS  (0) 2011.06.07
증강현실  (0) 2011.06.07
compass  (0) 2011.06.07
Location  (0) 2011.06.07
카메라  (0) 2011.06.07
Android <Activity - android:launchMode>  (0) 2011.05.30
posted by zerowns
프로그래밍/Android 2011.06.07 09:22
–<uses-permission android:name="android.permission.LOCATION"/>
–<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

  locMan= (LocationManager)ctx.getSystemService(Context.LOCATION_SERVICE);
locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 1, this);

publicvoidonLocationChanged(Location location){
if(curLocation== null) {
curLocation= location;
ARView.Location= location;
locationChanged= true;
}elseif(curLocation.getLatitude() == location.getLatitude() &&curLocation.getLongitude() == location.getLongitude())
{
locationChanged= false;
}else{
locationChanged= true;
}
curLocation= location;postInvalidate();


 

'프로그래밍 > Android' 카테고리의 다른 글

증강현실  (0) 2011.06.07
compass  (0) 2011.06.07
Location  (0) 2011.06.07
카메라  (0) 2011.06.07
Android <Activity - android:launchMode>  (0) 2011.05.30
Android Intent flag  (0) 2011.05.30
posted by zerowns
프로그래밍/Android 2011.06.07 09:19
•권한설정
–<uses-permission android:name="android.permission.CAMERA" />
 
•SurfaceViewfor Camera Capture Frame
 

public void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
cv = new CustomCameraView(this.getApplicationContext());
FrameLayoutfl = new FrameLayout(this.getApplicationContext());
setContentView(fl);
rl.addView(cv);
} catch (Exception e) {
}
}
 
Camera camera;
SurfaceHolderpreviewHolder;
publicCustomCameraView(Context ctx)
{
super(ctx);
previewHolder= this.getHolder();
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
previewHolder.addCallback(surfaceHolderListener);
}

SurfaceHolder.CallbacksurfaceHolderListener= newSurfaceHolder.Callback() {
publicvoidsurfaceCreated(SurfaceHolderholder) {
camera=Camera.open();
try{
camera.setPreviewDisplay(previewHolder);
}catch(Throwablet) {}
}


publicvoidsurfaceChanged(SurfaceHoldersurfaceHolder, intformat, intw, inth)
{
Parameters params= camera.getParameters();
params.setPreviewSize(320, 480);
params.setPictureFormat(PixelFormat.JPEG);
camera.setParameters(params);
camera.startPreview();


publicvoidsurfaceDestroyed(SurfaceHolderarg0){
// TODOAuto-generated method 
stubcamera.stopPreview();
camera.release();
}


 

'프로그래밍 > Android' 카테고리의 다른 글

compass  (0) 2011.06.07
Location  (0) 2011.06.07
카메라  (0) 2011.06.07
Android <Activity - android:launchMode>  (0) 2011.05.30
Android Intent flag  (0) 2011.05.30
Android 애니메이션  (0) 2011.05.30
posted by zerowns
프로그래밍/Android 2011.05.30 17:48
액티비티가 어떻게 런치되어야 하는 지에 대한 명령. 인텐트를 처리하기 위해 액티비티가 호출될 때 무엇이 발생해야 하는 지를 결정하기 위해, 인텐트 오브젝트의 액티비티 플래그(FLAG_ACTIVITY_* 상수)와 함께 동작하는 네 가지 모드가 있다. 그것은 다음과 같다.

"standard" "singleTop" "singleTask" "singleInstance"

디폴트의 모드는 “standard”이다
 

그 모드들은 두 가지 주요 그룹으로 나뉘어 진다. 한쪽에는 “standard” 와 “singleTop” 액티비티들이 있으며, 다른 한쪽에는 “singleTask” 와 “singleInstance”가 있다. “standard” 또는 “singleTop” 런치 모드를 가지는 액티비티는 여러 번 인스턴스화 될 수 있다. 인스턴스는 어떤 태스크에도 속할 수 있으며, 그리고 액티비티 스택의 어느 곳에든 놓여질 수 있다.
일반적으로 그것들은 startActivity()를 호출한 태스크에서 런치된다(인텐트 오브젝트가 FLAG_ACTIVITY_NEW_TASK 명령을 포함하지 않는 한 그러하며, 이 경우에는 다른 태스크가 선택되어 진다 - taskAffinity 애트리뷰트를 보라).
 

그에 반하여, “singleTask” 와 “singleInstance” 액티비티들은 오직 하나의 태스크를 시작할 수 있다. 그것들은 항상 액티비티 스택의 루트에 위치한다. 더욱이, 디바이스는 한 번에 ? 오직 하나의 그 태스크에서 오직 하나의 액티비티 인스턴스를 보유할 수 있다.
 

“standard” 와 “singleTop” 모드는 단지 한 측면에서만 서로 차이가 있다: “standard” 액티비티를 위한 신규 인텐트가 있을 때마다, 신규 클래스 인스턴스가 그 인텐트에 응답하기 위해 생성된다. 각각의 인스턴스는 하나의 인텐트를 처리한다. 비슷하게 “singleTop” 액티비티에 대한 신규 인스턴스 또한 신규 인텐트를 처리하기 위해 생성될 수 있다. 하지만 타겟 태스크가 이미 그것의 스택의 최상위에 그 액티비티에 대한 인스턴스를 가지고 있다면, 그 인스턴스가 신규 인텐트를 수신할 것이다(onNewIntent() 호출에서); 신규 인스턴스는 생성되지 않는다. 다른 상황에서는 - 예를 들어 만약 “singleTop” 액티비티에 대한 이미 존재하는 인스턴스가 타겟 태스크에 있으나 그것이 스택의 최상위에 있지 않다면, 또는 그것이 스택의 최상위에 있으나 타겟 태스크에는 있지 않다면 ? 신규 인스턴스는 생성될 것이고 스택에 푸쉬된다.

“singleTask” 와 “singleInstance” 모드들 또한 오직 한 측면에서만 서로 차이가 있다: “singleTask” 액티비티는 다른 액티비티가 그것의 태스크의 일부가 되는 것을 허용한다. 그것은 액티비티 스택의 루트에 있으나, 다른 액티비티들(반드시 “standard” 와 “singleTop” 액티비티)은 같은 태스크에서 런치될 수 있다. 반면에, “singleInstance” 액티비티는 어떤 액티비티도 그것의 태스크의 일부가 되는 것을 허용하지 않는다. 그것은 태스크 안에 있는 유일한 액티비티이다. 만약 그것이 다른 액티비티를 시작한다면, 그 액티비티는 다른 태스크에 할당된다 ? 마치 FLAG_ACTIVITY_NEW_TASK가 인텐트에 있었던 것처럼.

런치 모드와 인텐트 플래그를 사용한 그것들의 상호작용에 대한 더 많은 정보는, 2장. “애플리케이션 기초”의 “액티비티와 태스크”를 보라.


http://developer.android.com/guide/topics/manifest/activity-element.html

<activity android:allowTaskReparenting=["true" | "false"]
         
android:alwaysRetainTaskState=["true" | "false"]
         
android:clearTaskOnLaunch=["true" | "false"]
         
android:configChanges=["mcc", "mnc", "locale",
                                 
"touchscreen", "keyboard", "keyboardHidden",
                                 
"navigation", "orientation", "screenLayout",
                                 
"fontScale", "uiMode"]
         
android:enabled=["true" | "false"]
         
android:excludeFromRecents=["true" | "false"]
         
android:exported=["true" | "false"]
         
android:finishOnTaskLaunch=["true" | "false"]
         
android:hardwareAccelerated=["true" | "false"]
         
android:icon="drawable resource"
         
android:label="string resource"
         
android:launchMode=["multiple" | "singleTop" |
                             
"singleTask" | "singleInstance"]
         
android:multiprocess=["true" | "false"]
         
android:name="string"
         
android:noHistory=["true" | "false"]  
         
android:permission="string"
         
android:process="string"
         
android:screenOrientation=["unspecified" | "user" | "behind" |
                                     
"landscape" | "portrait" |
                                     
"sensor" | "nosensor"]
         
android:stateNotNeeded=["true" | "false"]
         
android:taskAffinity="string"
         
android:theme="resource or theme"
         
android:windowSoftInputMode=["stateUnspecified",
                                       
"stateUnchanged", "stateHidden",
                                       
"stateAlwaysHidden", "stateVisible",
                                       
"stateAlwaysVisible", "adjustUnspecified",
                                       
"adjustResize", "adjustPan"] >  
    . . .
</activity>  


'프로그래밍 > Android' 카테고리의 다른 글

Location  (0) 2011.06.07
카메라  (0) 2011.06.07
Android <Activity - android:launchMode>  (0) 2011.05.30
Android Intent flag  (0) 2011.05.30
Android 애니메이션  (0) 2011.05.30
Android 화면 고정  (0) 2011.05.30
posted by zerowns
프로그래밍/Android 2011.05.30 17:20
     Intent i = new Intent(this,myView.class);

    i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
 
     startActivity(i);        
 
    

http://developer.android.com/reference/android/content/Intent.html

int FLAG_ACTIVITY_BROUGHT_TO_FRONT
 
This flag is not normally set by application code, but set for you by the system as described in the launchMode documentation for the singleTask mode.
int FLAG_ACTIVITY_CLEAR_TASK If set in an Intent passed to Context.startActivity(), this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started.
int FLAG_ACTIVITY_CLEAR_TOP If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.
int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET If set, this marks a point in the task's activity stack that should be cleared when the task is reset.
int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS If set, the new activity is not kept in the list of recently launched activities.
int FLAG_ACTIVITY_FORWARD_RESULT If set and this intent is being used to launch a new activity from an existing one, then the reply target of the existing activity will be transfered to the new activity.
int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY This flag is not normally set by application code, but set for you by the system if this activity is being launched from history (longpress home key).
int FLAG_ACTIVITY_MULTIPLE_TASK Do not use this flag unless you are implementing your own top-level application launcher.
int FLAG_ACTIVITY_NEW_TASK If set, this activity will become the start of a new task on this history stack.
int FLAG_ACTIVITY_NO_ANIMATION If set in an Intent passed to Context.startActivity(), this flag will prevent the system from applying an activity transition animation to go to the next activity state.
int FLAG_ACTIVITY_NO_HISTORY If set, the new activity is not kept in the history stack.
int FLAG_ACTIVITY_NO_USER_ACTION If set, this flag will prevent the normal onUserLeaveHint() callback from occurring on the current frontmost activity before it is paused as the newly-started activity is brought to the front.
int FLAG_ACTIVITY_PREVIOUS_IS_TOP If set and this intent is being used to launch a new activity from an existing one, the current activity will not be counted as the top activity for deciding whether the new intent should be delivered to the top instead of starting a new one.
int FLAG_ACTIVITY_REORDER_TO_FRONT If set in an Intent passed to Context.startActivity(), this flag will cause the launched activity to be brought to the front of its task's history stack if it is already running.
int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED If set, and this activity is either being started in a new task or bringing to the top an existing task, then it will be launched as the front door of the task.
int FLAG_ACTIVITY_SINGLE_TOP If set, the activity will not be launched if it is already running at the top of the history stack.
int FLAG_ACTIVITY_TASK_ON_HOME If set in an Intent passed to Context.startActivity(), this flag will cause a newly launching task to be placed on top of the current home activity task (if there is one).
int FLAG_DEBUG_LOG_RESOLUTION A flag you can enable for debugging: when set, log messages will be printed during the resolution of this intent to show you what has been found to create the final resolved list.
int FLAG_EXCLUDE_STOPPED_PACKAGES If set, this intent will not match any components in packages that are currently stopped.
int FLAG_FROM_BACKGROUND Can be set by the caller to indicate that this Intent is coming from a background operation, not from direct user interaction.
int FLAG_GRANT_READ_URI_PERMISSION If set, the recipient of this Intent will be granted permission to perform read operations on the Uri in the Intent's data.
int FLAG_GRANT_WRITE_URI_PERMISSION If set, the recipient of this Intent will be granted permission to perform write operations on the Uri in the Intent's data.
int FLAG_INCLUDE_STOPPED_PACKAGES If set, this intent will always match any components in packages that are currently stopped.
int FLAG_RECEIVER_REGISTERED_ONLY If set, when sending a broadcast only registered receivers will be called -- no BroadcastReceiver components will be launched.
int FLAG_RECEIVER_REPLACE_PENDING If set, when sending a broadcast the new broadcast will replace any existing pending broadcast that matches it.

'프로그래밍 > Android' 카테고리의 다른 글

카메라  (0) 2011.06.07
Android <Activity - android:launchMode>  (0) 2011.05.30
Android Intent flag  (0) 2011.05.30
Android 애니메이션  (0) 2011.05.30
Android 화면 고정  (0) 2011.05.30
Android 저장 경로  (0) 2011.05.30
posted by zerowns

티스토리 툴바