急问,在IntentService里怎么让MainActivity里的Fragment弹出窗口
急问,在IntentService里如何让MainActivity里的Fragment弹出窗口
MainActivity里有3个actionBar.Tab,每个Tab都是一个独立的Fragment。
现在MainActivity里开了一个IntentService,在这个IntentService的onHandleIntent方法里,会一直监控比如是否进入指定地点。如果现在第二个Fragment是打开的,而且手机也进入指定地点,就让这个Fragment弹出一个PopUp窗口。
我现在其他部分都做好了,手机进入指定地点能发Notification(后台IntentService是正常的),Fragment里也能弹Popup窗口。就不知道怎么在第二个Fragment里接收IntentService的onHandleIntent方法里手机进入指定地点的状态。
我现在想能不能再第二个Fragment里bindService,就是绑定MainActivity里生成的Service,这样当触发到达地点时就可以在Fragment里显示Popup窗口了,可不知道行不行。
这个是IntentService监控地理位置的代码
这个是第二个Fragment的代码
------解决思路----------------------
几种方法
一、如果你能访问点fragment,可以直接调用
二、发广播,fragment里接收到后弹出窗口
------解决思路----------------------
上面有人很简短的说明了啊。2楼
MainActivity里有3个actionBar.Tab,每个Tab都是一个独立的Fragment。
现在MainActivity里开了一个IntentService,在这个IntentService的onHandleIntent方法里,会一直监控比如是否进入指定地点。如果现在第二个Fragment是打开的,而且手机也进入指定地点,就让这个Fragment弹出一个PopUp窗口。
我现在其他部分都做好了,手机进入指定地点能发Notification(后台IntentService是正常的),Fragment里也能弹Popup窗口。就不知道怎么在第二个Fragment里接收IntentService的onHandleIntent方法里手机进入指定地点的状态。
我现在想能不能再第二个Fragment里bindService,就是绑定MainActivity里生成的Service,这样当触发到达地点时就可以在Fragment里显示Popup窗口了,可不知道行不行。
这个是IntentService监控地理位置的代码
public class GeofenceIntentService extends IntentService {
protected void onHandleIntent(Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
Log.v(TAG, "onHandleIntent");
if(!geofencingEvent.hasError()) {
int transition = geofencingEvent.getGeofenceTransition();
String notificationTitle;
switch(transition) {
case Geofence.GEOFENCE_TRANSITION_ENTER:
notificationTitle = "Geofence Entered";
break;
default:
notificationTitle = "Geofence Unknown";
}
sendNotification(this, getTriggeringGeofences(intent), notificationTitle);
}
}}
这个是第二个Fragment的代码
public class Tab_Results extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tab_results, container, false);
return view;
}
}
------解决思路----------------------
几种方法
一、如果你能访问点fragment,可以直接调用
二、发广播,fragment里接收到后弹出窗口
------解决思路----------------------
上面有人很简短的说明了啊。2楼