Yes, I understand what you saying. but I just wanna know it is possible from the viewpoint of technic. I think it's not perfect solution comparing with package name in my code. // activity.packageName.equals(strPackage) I guess there are weak points I haven't thought of.
On 7월27일, 오후11시56분, Joseph Earl <joseph.w.e...@gmail.com> wrote: > It would be reasonable to start a service when the device is idle. > I think it would be unreasonable to start a visible activity without > user interaction. The user will start your app when they want to. > > On Jul 27, 3:47 am, optimusgeek <choongb...@gmail.com> wrote: > > > > > I want to start my activity when the device is in idle(home screen). > > I found a solution like below. > > > ================================================= > > ActivityManager actvityManager = > > (ActivityManager)getSystemService( ACTIVITY_SERVICE ); > > List<ActivityManager.RunningTaskInfo> task = > > actvityManager.getRunningTasks(1); > > ComponentName topActivity = task.get(0).topActivity; > > String strPackage = topActivity.getPackageName(); > > > PackageManager pm = getPackageManager(); > > Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); > > mainIntent.addCategory(Intent.CATEGORY_HOME); > > List<ResolveInfo> mApps; > > mApps = pm.queryIntentActivities(mainIntent, 0); > > > int count = mApps.size(); > > > for(int i=0; i<count; i++){ > > ResolveInfo info = mApps.get(i); > > ActivityInfo activity = info.activityInfo; > > if(activity.packageName.equals(strPackage)) > > { > > return true; > > }} > > > return false; > > =============================================== > > > Is that reasonable?? I'm not sure there is more good solution. > > please give me any opinion. > > thank you.- 원본 텍스트 숨기기 - > > - 원본 텍스트 보기 - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en