intent
안드로이드 이 동작과 관련된 모든 앱이 해제 또는 차단되었거나 설치되지 않았습니다 해결
이건 또 뭔 말인지..
단지 그냥 버튼 누르면 액티비티 시작하게 하려고 했는데
이 동작과 관련된 모든 앱이 해제 또는 차단되었거나 설치되지 않았습니다
이게 토스트메시지로 뜨면서 되질 않는다.
구글 찾아봐도 다 토렌트 얘기하고 그러는데 영문 메시지로 검색해도 뭐가 뭔지 영..
그러다 네이버로 검색해보았떠니
http://blog.naver.com/mdroid_16/220903491982
이런 해결책이 있다고 한다 . 쓰일 함수 안에 intent를 넣어주었더니 해결되었다라..
그래서 시도해보았다.
처음 코드 상태가
이런 식으로 되어있어서 저 Intent it 코드를 OnTouchListener 안에 넣어보았다.
그랬더니 이런 에러가 뜬다.
에러메시지 검색해서 찾아보니
https://stackoverflow.com/questions/20241857/android-intent-cannot-resolve-constructor
여기서 해보라는데로 해보았다.
Intent it = new Intent(this, DBActivity.class); > Intent it = new Intent(v.getContext(), DBActivity.class); 로 수정
this > v.getContext()
이렇게 바꿔주었다.
그랬더니 된다.
다행이다.
'지식메모 > 안드로이드 Android' 카테고리의 다른 글
안드로이드 Intent로 액티비티 시작시 에러 android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag 해결
인텐트로 다른 액티비티를 시작하고자 했는데 에러가 발생
startActivity(it); //에러 발생
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | // input your code herepublic class AlwaysTopServiceTouch extends Service { private View mView; private WindowManager mManager; private WindowManager.LayoutParams mParams; private float mTouchX, mTouchY; private int mViewX, mViewY; private boolean isMove = false; Intent it = new Intent(this, DBActivity.class); private OnTouchListener mViewTouchListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: isMove = false; mTouchX = event.getRawX(); mTouchY = event.getRawY(); mViewX = mParams.x; mViewY = mParams.y; break; case MotionEvent.ACTION_UP: if (!isMove) { // Toast.makeText(getApplicationContext(), "???", // Toast.LENGTH_SHORT).show(); startActivity(it); //에러 발생 } | cs |
에러 코드는
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
플래그 어쩌구 저쩌구 FLAG_ACTIVITY_NEW_TASK 이게 요구된다는데
확인결과
서비스는 태스크가 없기 때문에 액티비티를 시작하려면 new task 플래그를 줘야 한다고 한다.
그래서 코드수정
startActivity(it) 를
startActivity(it.addFlags(FLAG_ACTIVITY_NEW_TASK));
위와 같이 수정하니 에러가 발생하지 않았다.
'지식메모 > 안드로이드 Android' 카테고리의 다른 글
안드로이드 터치 한번으로 글자 복사하기 (0) | 2017.07.26 |
---|---|
안드로이드 이 동작과 관련된 모든 앱이 해제 또는 차단되었거나 설치되지 않았습니다 해결 (0) | 2017.07.17 |
Android 손쉽게 권한 획득 가능한 라이브러리 TedPermission (0) | 2017.07.11 |
안드로이드 버튼 배경 투명하게 하는법 (0) | 2017.04.04 |
안드로이드 마쉬멜로우 6.0 권한 허용 팝업 기능 추가하기 (0) | 2016.08.02 |