안드로이드 개발 질문/답변
(글 수 45,052)
public class BRcvr extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){
//ComponentName cn = new ComponentName(context.getPackageName(), BootSvc.class.getName());
//ComponentName svcName = context.startService(new Intent().setComponent(cn));
ComponentName cn = new ComponentName(context.getPackageName(), TestClass.class.getName());
ComponentName clsName = context.startActivity(new Intent().setComponent(cn));
...........생략
브로드캐스트 리시버를 상속받아 문자가 왔을때 반응하는 Activity를 띄우려고하는데요;
빨간색 부분이 코드상(실행단계아님) 에러가 Type mismatch: cannot convert from void to ComponentName 이렇게 나오네요;
저 줄 위에있는 주석 걸린부분의 서비스 호출하는건 잘 되는데...액티비티 호출하는건 왜 저렇게 나오는걸까요?;;
서비스 호출한부분에서 액티비티를 호출해야하는건가요?;;
참고로 전에도 같은 질문을해서
Intent itnt = new Intent(context, TestClass.class);
itnt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//이곳 이상 안넘어감
context.startActivity(itnt);
이런 방식으로 해보라는 답변을 받았는데 코드상에는 에러는 안나는데 실행단계에서
빨간색친 마지막 줄에서 에러가 나더라구요.
도움좀 주세요~ㅜ_ㅜ
PS:시간이 되시면 위의방법과 아래의 방법이 어떻게 다른지도 설명을 좀 부탁드립니다.