项目:FCM-for-Mojo
文件:FFMIntentService.java
@Override
protected void onHandleIntent(Intent intent) {
if (intent == null) {
return;
}
final String action = intent.getAction();
if (ACTION_UPDATE_ICON.equals(action)) {
ResultReceiver receiver = intent.getParcelableExtra(Intent.EXTRA_RESULT_RECEIVER);
handleUpdateIcon(receiver);
} else if (ACTION_REPLY.equals(action)) {
CharSequence content = intent.getCharSequenceExtra(EXTRA_CONTENT);
Chat chat = intent.getParcelableExtra(EXTRA_CHAT);
handleReply(content,chat);
} else if (ACTION_DOWNLOAD_QRCODE.equals(action)) {
handleDownloadQrCode();
} else if (ACTION_RESTART_WEBQQ.equals(action)) {
handleRestart();
}
}
项目:Camera-Background-Servce
文件:MainActivity.java
private void startRecording() {
if (!mHandlingEvent) {
mHandlingEvent = true;
ResultReceiver receiver = new ResultReceiver(new Handler()) {
@Override
protected void onReceiveResult(int resultCode,Bundle resultData) {
setRecording(true);
handleStartRecordingResult(resultCode,resultData);
mHandlingEvent = false;
}
};
if (mFronTradioButton.isChecked()) {
CameraService.startToStartRecording(this,Camera.CameraInfo.CAMERA_FACING_FRONT,receiver);
} else if (mBackRadioButton.isChecked()) {
CameraService.startToStartRecording(this,receiver);
} else {
throw new IllegalStateException("Must choose a camera for recording");
}
}
}
项目:letv
文件:MediaControllerCompat.java
public void sendCommand(String command,Bundle params,ResultReceiver cb) {
try {
this.mBinder.sendCommand(command,params,new ResultReceiverWrapper(cb));
} catch (remoteexception e) {
Log.e(MediaControllerCompat.TAG,"Dead object in sendCommand. " + e);
}
}
项目:microbit
文件:DfuBaseService.java
@Override
protected void onHandleIntent(final Intent intent) {
int phase = intent.getIntExtra(INTENT_REQUESTED_PHASE,0) & 0x03;
resultReceiver = (ResultReceiver) intent.getParcelableExtra(INTENT_RESULT_RECEIVER);
delayForInitDeviceFirmware = intent.getLongExtra(EXTRA_WAIT_FOR_INIT_DEVICE_FIRMWARE,0);
int rc = 0;
logi("DFUBaseService onHandleIntent phase = " + phase);
mServicePhase = 0;
if ((phase & FLASHING_WITH_PAIR_CODE) != 0) {
mServicePhase = FLASHING_WITH_PAIR_CODE;
rc = flashingWithPairCode(intent);
}
if (resultReceiver != null) {
rc <<= 8;
resultReceiver.send(rc | phase,null);
}
}
AutoCompleteTextViewReflector() {
try {
this.dobeforeTextChanged = AutoCompleteTextView.class.getDeclaredMethod("dobeforeTextChanged",new Class[0]);
this.dobeforeTextChanged.setAccessible(true);
} catch (NoSuchMethodException e) {
}
try {
this.doAfterTextChanged = AutoCompleteTextView.class.getDeclaredMethod("doAfterTextChanged",new Class[0]);
this.doAfterTextChanged.setAccessible(true);
} catch (NoSuchMethodException e2) {
}
try {
this.ensureImeVisible = AutoCompleteTextView.class.getmethod("ensureImeVisible",new Class[]{Boolean.TYPE});
this.ensureImeVisible.setAccessible(true);
} catch (NoSuchMethodException e3) {
}
try {
this.showSoftInputUnchecked = InputMethodManager.class.getmethod("showSoftInputUnchecked",new Class[]{Integer.TYPE,ResultReceiver.class});
this.showSoftInputUnchecked.setAccessible(true);
} catch (NoSuchMethodException e4) {
}
}
@Override
public int onStartCommand(Intent intent,int flags,int startId) {
if (intent != null && intent.getAction() != null) {
if (intent.getAction().equals(ACTION_RECORDING_START)) {
if (intent.hasExtra(EXTRA_SAMPLING_RATE)) {
mSamplingRate = intent.getIntExtra(EXTRA_SAMPLING_RATE,DEFAULT_SAMPLING_RATE);
}
startRecording();
return START_STICKY;
} else if (intent.getAction().equals(ACTION_RECORDING_STOP)) {
stopRecording();
return START_STICKY;
} else if (intent.getAction().equals(ACTION_RECORDING_GET_STATUS)) {
ResultReceiver receiver = intent.getParcelableExtra("receiver");
Bundle data = new Bundle();
data.putInt(EXTRA_RECORDING_STATUS,mRecordingStatus);
receiver.send(0,data);
return START_STICKY;
}
}
stopSelf();
return START_NOT_STICKY;
}
private void maybeProcessstartIntent() {
if (mStartIntent == null || mTorchStatus == TORCH_STATUS_UNKNowN) return;
if (ACTION_TOGGLE_TORCH.equals(mStartIntent.getAction())) {
if (DEBUG) Log.d(TAG,"maybeProcessstartIntent: ACTION_TOGGLE_TORCH");
toggletorch();
} else if (ACTION_TORCH_GET_STATUS.equals(mStartIntent.getAction())) {
if (DEBUG) Log.d(TAG,"maybeProcessstartIntent: " +
"ACTION_TORCH_GET_STATUS: mTorchStatus=" + mTorchStatus);
ResultReceiver receiver = mStartIntent.getParcelableExtra("receiver");
Bundle data = new Bundle();
data.putInt(EXTRA_TORCH_STATUS,mTorchStatus);
receiver.send(0,data);
}
mStartIntent = null;
}
private static void sendNfcState(ResultReceiver receiver) {
if (mContext == null || receiver == null) return;
int nfcState = NFC_STATE_UNKNowN;
try {
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext);
if (adapter != null) {
nfcState = (Integer) XposedHelpers.callMethod(adapter,"getAdapterState");
}
} catch (Throwable t) {
XposedBridge.log(t);
} finally {
Bundle b = new Bundle();
b.putInt("nfcState",nfcState);
receiver.send(0,b);
}
}
项目:solved-hacking-problem
文件:cu.java
cu() {
try {
this.f1479a = AutoCompleteTextView.class.getDeclaredMethod("dobeforeTextChanged",new Class[0]);
this.f1479a.setAccessible(true);
} catch (NoSuchMethodException e) {
}
try {
this.f1480b = AutoCompleteTextView.class.getDeclaredMethod("doAfterTextChanged",new Class[0]);
this.f1480b.setAccessible(true);
} catch (NoSuchMethodException e2) {
}
try {
this.f1481c = AutoCompleteTextView.class.getmethod("ensureImeVisible",new Class[]{Boolean.TYPE});
this.f1481c.setAccessible(true);
} catch (NoSuchMethodException e3) {
}
try {
this.f1482d = InputMethodManager.class.getmethod("showSoftInputUnchecked",ResultReceiver.class});
this.f1482d.setAccessible(true);
} catch (NoSuchMethodException e4) {
}
}
项目:science-journal
文件:KeyboardUtil.java
/**
* Returns Observable that will receive true if the keyboard is closed
*/
public static Single<Boolean> closeKeyboard(Activity activity) {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(
Context.INPUT_METHOD_SERVICE);
return Single.create(s -> {
imm.hideSoftInputFromWindow(view.getwindowToken(),new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode,Bundle resultData) {
s.onSuccess(resultCode == InputMethodManager.RESULT_HIDDEN);
super.onReceiveResult(resultCode,resultData);
}
});
});
} else {
return Single.just(false);
}
}
项目:StraaS-android-sdk-sample
文件:MediaControllerCompatHelper.java
/**
* Retrieve all video {@link Format} and current selected index from current media playback.
* <p>
* Later you Could use {@link MediaControllerCompatHelper#setVideoQualityIndex(Activity,int)}
* or {@link MediaControllerCompatHelper#setVideoQualityIndex(MediaControllerCompat,int)} to
* change new index.
*/
public static void getVideoQualityInfo(@NonNull MediaControllerCompat controller,@NonNull final VideoQualityInfoCallback callback) {
controller.sendCommand(StraasMediaCore.COMMAND_GET_VIDEO_FORMATS,null,new ResultReceiver(new Handler()) {
@Override
protected void onReceiveResult(int resultCode,Bundle resultData) {
resultData.setClassLoader(Format.class.getClassLoader());
if (resultData.containsKey(StraasMediaCore.KEY_CURRENT_VIDEO_FORMAT_INDEX)) {
ArrayList<Format> formats = resultData.getParcelableArrayList(StraasMediaCore.KEY_ALL_VIDEO_FORMATS);
int selectedindex = resultData.getInt(StraasMediaCore.KEY_CURRENT_VIDEO_FORMAT_INDEX);
callback.onGetVideoQualityInfo(new VideoQualityInfo(formats,selectedindex));
}
}
});
}
项目:DeviceConnect-Android
文件:WarningDialogFragment.java
@Override
public void onStop() {
super.onStop();
if (!mdisableFlg) {
Intent i = new Intent();
i.setAction(DConnectObservationService.ACTION_START);
i.setClass(getActivity(),ObserverReceiver.class);
i.putExtra(DConnectObservationService.ParaM_RESULT_RECEIVER,new ResultReceiver(new Handler()) {
@Override
protected void onReceiveResult(int resultCode,Bundle resultData) {
}
});
getActivity().sendbroadcast(i);
}
getActivity().finish();
}
项目:DeviceConnect-Android
文件:SonyCameraConnectingFragment.java
/**
* WiFiスキャンを行うには位置情報のパーミッション許可が必要なので、確認を行う.
*/
private void checkLocationServiceEnabled() {
// WiFi scan in SDK 23 requires location service to be enabled.
final LocationManager manager = getContext().getSystemService(LocationManager.class);
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
IntentHandlerActivity.startActivityForResult(getContext(),new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),new ResultReceiver(new Handler(Looper.getMainLooper())) {
@Override
protected void onReceiveResult(int resultCode,final Bundle resultData) {
super.onReceiveResult(resultCode,resultData);
if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
checkLocationPermission();
} else {
showErrorDialog(getString(R.string.sonycamera_request_permission_error));
}
}
});
} else {
checkLocationPermission();
}
}
项目:digits-android
文件:LoginCodeController.java
LoginCodeController(ResultReceiver resultReceiver,StateButton stateButton,InvertedStateButton resendButton,InvertedStateButton callMeButton,SpacedEditText loginEditText,SessionManager<DigitsSession> sessionManager,DigitsClient client,String requestId,long userId,String phoneNumber,ErrorCodes errors,ActivityClassManager activityClassManager,DigitsEventCollector digitsEventCollector,Boolean emailCollection,TextView timerText,DigitsEventDetailsBuilder details) {
super(resultReceiver,stateButton,loginEditText,client,errors,activityClassManager,sessionManager,digitsEventCollector,details);
this.requestId = requestId;
this.userId = userId;
this.phoneNumber = phoneNumber;
this.emailCollection = emailCollection;
this.resendButton = resendButton;
this.callMeButton = callMeButton;
this.countDownTimer = createCountDownTimer(
DigitsConstants.RESEND_TIMER_DURATION_MILLIS,timerText,resendButton,callMeButton);
this.timerText = timerText;
this.loginEditText = loginEditText;
}
项目:MAST-MOBILE
文件:DownloadService.java
private void startDataDownloading(ResultReceiver receiver,String userid) throws IOException {
// First check for config being downloaded
DbController db = DbController.getInstance(getApplicationContext());
if (db.getClaimTypes(false).size() < 1) {
if(!startConfigDownloading(null,userid)){
receiver.send(STATUS_ERROR,Bundle.EMPTY);
return;
}
}
displayNotification("MAST",getResources().getString(R.string.DownloadingData),getResources().getString(R.string.Downloading));
if(downloadProperties(userid)){
updateNotification("MAST",getResources().getString(R.string.DataDownloadSuccessful),getResources().getString(R.string.DownloadFinished));
receiver.send(STATUS_FINISHED,Bundle.EMPTY);
} else {
updateNotification("MAST",getResources().getString(R.string.DataDownloadFailed),getResources().getString(R.string.DownloadError));
receiver.send(STATUS_ERROR,Bundle.EMPTY);
}
}
项目:digits-android
文件:ConfirmationCodeController.java
/**
* Only for test
*/
ConfirmationCodeController(ResultReceiver resultReceiver,SpacedEditText confirmationEditText,boolean isEmailCollection,DigitsEventDetailsBuilder digitsEventDetailsBuilder) {
super(resultReceiver,confirmationEditText,digitsEventDetailsBuilder);
this.phoneNumber = phoneNumber;
this.isEmailCollection = isEmailCollection;
this.resendButton = resendButton;
this.callMeButton = callMeButton;
this.countDownTimer = createCountDownTimer(
DigitsConstants.RESEND_TIMER_DURATION_MILLIS,callMeButton);
this.timerText = timerText;
this.confirmationEditText = confirmationEditText;
}
项目:digits-android
文件:DigitsControllerImpl.java
DigitsControllerImpl(ResultReceiver resultReceiver,EditText editText,DigitsEventDetailsBuilder eventDetailsBuilder) {
this.resultReceiver = resultReceiver;
this.digitsClient = client;
this.activityClassManager = activityClassManager;
this.sendButton = stateButton;
this.editText = editText;
this.errors = errors;
this.sessionManager = sessionManager;
this.errorCount = 0;
this.digitsEventCollector = digitsEventCollector;
this.eventDetailsBuilder = eventDetailsBuilder;
}
项目:HackNews
文件:HNServiceHelper.java
public long getItems() {
Logger.d("[HNServiceHelper] thread id: " + Thread.currentThread().getId());
long requestId = generateRequestId();
ResultReceiver serviceCallback = new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode,Bundle resultData) {
handleGetItemsResponse(resultCode,resultData);
}
};
Intent intent = new Intent(this.mContext,HNService.class);
intent.putExtra(HNService.METHOD_EXTRA,HNService.METHOD_GET);
intent.putExtra(HNService.RESOURCE_TYPE_EXTRA,HNService.RESOURCE_TYPE_ITEMS);
intent.putExtra(HNService.SERVICE_CALLBACK,serviceCallback);
intent.putExtra(REQUEST_ID,requestId);
this.mContext.startService(intent);
return requestId;
}
项目:FixMyNumber
文件:ServiceHelper.java
private Intent createIntent(final Context context,String action,final int requestId) {
Intent i = new Intent(context,TaskService.class);
i.setAction(action);
i.putExtra(TaskService.EXTRA_STATUS_RECEIVER,new ResultReceiver(new Handler()) {
@Override
protected void onReceiveResult(int resultCode,Bundle resultData) {
Intent originalIntent = pendingActivities.get(requestId);
if (isPending(requestId)) {
if (resultCode != IntentHandler.PROGRESS_CODE) {
pendingActivities.remove(requestId);
}
for (ServiceCallbackListener currentListener : currentListeners) {
if (currentListener != null) {
currentListener.onServiceCallback(requestId,originalIntent,resultCode,resultData);
}
}
}
}
});
return i;
}
项目:digits-android
文件:DigitsControllerTests.java
@Override
public void setUp() throws Exception {
super.setUp();
bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
callbackCaptor = ArgumentCaptor.forClass(DigitsCallback.class);
intentCaptor = ArgumentCaptor.forClass(Intent.class);
phoneEditText = mock(SpacedEditText.class);
sendButton = mock(StateButton.class);
resendButton = mock(InvertedStateButton.class);
callMeButton = mock(InvertedStateButton.class);
digitsClient = mock(DigitsClient.class);
context = mock(Activity.class);
resultReceiver = mock(ResultReceiver.class);
sessionManager = new DummySessionManager(mock(DigitsSession.class));
errors = mock(ErrorCodes.class);
digitsEventCollector = mock(DummyDigitsEventCollector.class);
countDownTimer = mock(CountDownTimer.class);
timerTextView = mock(TextView.class);
digitsEventDetailsArgumentCaptor = ArgumentCaptor.forClass(DigitsEventDetails.class);
when(context.getPackageName()).thenReturn(getClass().getPackage().toString());
when(context.getResources()).thenReturn(getContext().getResources());
}
项目:murex-coding-dojo
文件:TimerService.java
@Override
protected void onHandleIntent(Intent intent) {
final ResultReceiver rec = intent.getParcelableExtra(RECEIVER_TAG);
new Thread() {
int seconds;
@Override
public void run() {
while (seconds < 100) {
Bundle b = new Bundle();
b.putString(SERVICE_TAG,String.valueOf(seconds++));
rec.send(0,b);
try {
sleep(1000);
} catch (InterruptedException e) {
e.printstacktrace();
}
}
}
}.start();
}
@Test
public void testSetUpTryAnotherPhoneButton() {
delegate.eventDetailsBuilder = new DigitsEventDetailsBuilder()
.withLanguage("lang")
.withCountry("US")
.withAuthStartTime(1L);
delegate.setUpTryAnotherPhoneButton(button);
verify(button).setonClickListener(captorClick.capture());
final View.OnClickListener listener = captorClick.getValue();
listener.onClick(null);
verify(digitsEventCollector).retryClickOnFailureScreen(detailsArgumentCaptor.capture());
final DigitsEventDetails details = detailsArgumentCaptor.getValue();
assertNotNull(details.language);
assertNotNull(details.country);
assertNotNull(details.elapsedtimeInMillis);
verify(controller).tryAnotherNumber(eq(activity),any(ResultReceiver.class));
verify(activity).finish();
}
项目:tuchong-daily-android
文件:PostsService.java
private void handleRequestPosts(Intent originalIntent,ResultReceiver receiver,int skip,int limit) {
DataPosts dataPosts = APIFactory.instance().getPosts(skip,limit).getData();
sendDataToReceiver(receiver,dataPosts);
ArrayList<Post> posts = dataPosts.getPosts();
if (skip == 0) {
getContentResolver().delete(PostProvider.uriPosts(),null);
getContentResolver().delete(ImageProvider.uriImages(),null);
}
for (Post post : posts) {
ArrayList<Image> images = post.getimages();
if (images != null) {
for (Image image : images) {
//delete related images
getContentResolver().delete(ImageProvider.uriImage(image.getPostId()),null);
}
}
post.save(this);
}
}
项目:sagetv-miniclient
文件:MiniClientGDXActivity.java
void initMediaSession() {
// NOTE: all this is so that when you press pause/play in the app,we can capture the
// media control event,so that other apps DON'T (ie,google play music,plex,etc).
// ideally we Could do something useful with this,but for not,just eat it.
try {
ComponentName mediaButtonReceiver = new ComponentName(getApplicationContext(),MediaButtonReceiver.class);
mediaSessionCompat = new MediaSessionCompat(getApplicationContext(),"SAGETVMINICLIENT",mediaButtonReceiver,null);
mediaSessionCompat.setCallback(new MediaSessionCompat.Callback() {
@Override
public void onCommand(String command,Bundle extras,ResultReceiver cb) {
log.debug("Audio Session Callback Handler: Command {}",command);
}
});
mediaSessionCompat.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS);
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setClass(this,MediaButtonReceiver.class);
PendingIntent pendingIntent = PendingIntent.getbroadcast(this,mediaButtonIntent,0);
mediaSessionCompat.setMediaButtonReceiver(pendingIntent);
mediaSessionCompat.setActive(true);
log.debug("Media Session is setup to capture pause/play. session: "+mediaSessionCompat.getSessionToken());
} catch (Throwable t) {
log.error("Failed to capture the media session",t);
}
}
@Override
public void onResponse(JSONObject response) {
switch (mType) {
case Api.TYPE_LATEST:
Api.parseLatestTopics(response);
break;
case Api.TYPE_CATEGORIES:
Api.parseCategories(response);
break;
}
ResultReceiver rr = mCallbacks.get(mType);
if (rr != null) {
rr.send(Activity.RESULT_OK,null);
mCallbacks.delete(mType);
}
}
public InputStream getInputStream(String link,ResultReceiver receiver) {
if (MyApp.getInstance().isOnline(getBaseContext())) {
try {
URL url = new URL(link);
URLConnection connection = url.openConnection();
connection
.setConnectTimeout(InformerConstants.TIMEOUT_CONNECTION);
connection.setReadTimeout(InformerConstants.TIMEOUT_CONNECTION);
return connection.getInputStream();
} catch (IOException e) {
return null;
}
} else {
receiver.send(ERROR_CODE,null);
}
return null;
}
项目:PeSanKita-android
文件:WebRtcCallService.java
private void handleIsInCallQuery(Intent intent) {
ResultReceiver resultReceiver = intent.getParcelableExtra(EXTRA_RESULT_RECEIVER);
if (resultReceiver != null) {
resultReceiver.send(callState != CallState.STATE_IDLE ? 1 : 0,null);
}
}
项目:PeSanKita-android
文件:WebRtcCallService.java
public static void isCallActive(Context context,ResultReceiver resultReceiver) {
Intent intent = new Intent(context,WebRtcCallService.class);
intent.setAction(ACTION_IS_IN_CALL_QUERY);
intent.putExtra(EXTRA_RESULT_RECEIVER,resultReceiver);
context.startService(intent);
}
项目:CSipSimple
文件:SearchView.java
private static void showSoftInputUnchecked(View view,InputMethodManager imm,int flags) {
try {
Method method = imm.getClass().getmethod("showSoftInputUnchecked",int.class,ResultReceiver.class);
method.setAccessible(true);
method.invoke(imm,flags,null);
} catch (Exception e) {
//Fallback to public API which hopefully does mostly the same thing
imm.showSoftInput(view,flags);
}
}
项目:FuelFriend
文件:DownloadService.java
@Override
protected void onHandleIntent(@Nullable Intent intent) {
if(!PreferenceHelper.isSynced(getApplicationContext())) {
final ResultReceiver receiver = intent.getParcelableExtra("receiver");
Bundle bundle = new Bundle();
String urlPart = "http://hproroute.hpcl.co.in/StatedistrictMap_4/fetchmshsdprice.jsp?param=T&statecode=";
long time = System.currentTimeMillis();
List<State> stateList = DatabaseHelper.getStates(getApplicationContext(),true);
mFuelPriceList = new ArrayList<>();
for (int i = 0; i < stateList.size(); i++) {
State state = stateList.get(i);
String result = "State : " + state.getName();
fullUrl = urlPart + state.getCode() + "?" + time;
try {
result += downloadData(fullUrl);
bundle.putString("result",result);
receiver.send(STATUS_FINISHED,bundle);
} catch (Exception e) {
bundle.putString(Intent.EXTRA_TEXT,e.toString());
receiver.send(STATUS_ERROR,bundle);
}
}
DatabaseHelper.updateFuelPrice(getApplicationContext(),mFuelPriceList);
PreferenceHelper.setCurrentDataDownloadDate(getApplicationContext());
receiver.send(STATUS_FINISHED,bundle);
Log.d(TAG,"service stopping");
}
}
项目:FuelFriend
文件:AlarmReceiver.java
@Override
public void onReceive(Context context,Intent intent) {
Intent i = new Intent(context,DownloadService.class);
ResultReceiver receiver = intent.getParcelableExtra("receiver");
i.putExtra("receiver",receiver);
context.startService(i);
}
项目:Camera-Background-Servce
文件:MainActivity.java
private void stopRecording() {
if (!mHandlingEvent) {
mHandlingEvent = true;
ResultReceiver receiver = new ResultReceiver(new Handler()) {
@Override
protected void onReceiveResult(int resultCode,Bundle resultData) {
setRecording(false);
handleStopRecordingResult(resultCode,resultData);
mHandlingEvent = false;
}
};
CameraService.startToStopRecording(this,receiver);
}
}
项目:Camera-Background-Servce
文件:CameraService.java
public static void startToStartRecording(Context context,int cameraId,ResultReceiver resultReceiver) {
Intent intent = new Intent(context,CameraService.class);
intent.putExtra(START_SERVICE_COMMAND,COMMAND_START_RECORDING);
intent.putExtra(SELECTED_CAMERA_FOR_RECORDING,cameraId);
intent.putExtra(RESULT_RECEIVER,resultReceiver);
context.startService(intent);
}
项目:Camera-Background-Servce
文件:CameraService.java
private void handleStopRecordingCommand(Intent intent) {
ResultReceiver resultReceiver = null;
if(intent != null)
resultReceiver = intent.getParcelableExtra(RESULT_RECEIVER);
if (!mRecording) {
// have not recorded
if (resultReceiver != null)
resultReceiver.send(RECORD_RESULT_NOT_RECORDING,null);
return;
}
try {
mMediaRecorder.stop();
mMediaRecorder.release();
} catch (RuntimeException e) {
mMediaRecorder.reset();
if (resultReceiver != null)
resultReceiver.send(RECORD_RESULT_UNSTOPPABLE,new Bundle());
return;
} finally {
mMediaRecorder = null;
mCamera.stopPreview();
mCamera.release();
mRecording = false;
SharedPreferenceHelper.getInstance().saveIsRecording(mRecording);
}
Bundle b = new Bundle();
b.putString(VIDEO_PATH,mRecordingPath);
if (resultReceiver != null)
resultReceiver.send(RECORD_RESULT_OK,b);
Log.d(TAG,"recording is finished.");
}
项目:nifi-android-s2s
文件:QueuedOperationResultCallback.java
/**
* Sends the given result to the receiver
*
* @param resultReceiver the receiver
*/
public static void onSuccess(ResultReceiver resultReceiver) {
if (resultReceiver == null) {
return;
}
resultReceiver.send(0,new Bundle());
}
项目:nifi-android-s2s
文件:QueuedOperationResultCallback.java
/**
* Sends the given exception to the receiver
*
* @param resultReceiver the receiver
* @param exception the exception
*/
public static void onException(ResultReceiver resultReceiver,IOException exception) {
if (resultReceiver == null) {
return;
}
Bundle resultData = new Bundle();
resultData.putSerializable(IO_EXCEPTION,exception);
resultReceiver.send(1,resultData);
}
项目:nifi-android-s2s
文件:TransactionResultCallback.java
/**
* Sends the given result to the receiver
*
* @param resultReceiver the receiver
* @param transactionResult the result
*/
public static void onSuccess(ResultReceiver resultReceiver,TransactionResult transactionResult) {
if (resultReceiver == null) {
return;
}
Bundle resultData = new Bundle();
resultData.putParcelable(RESULT,transactionResult);
resultReceiver.send(0,resultData);
}
项目:nifi-android-s2s
文件:TransactionResultCallback.java
@Override
protected void onHandleIntent(@Nullable Intent intent) {
Log.v(TAG,"onHandleIntent");
Geocoder geocoder = new Geocoder(this,Locale.getDefault());
String errorMessage = "";
// Get the location passed to this service through an extra.
ArrayList<GitHubUserLocationDataEntry> locationsList = intent.getParcelableArrayListExtra(
LocationConstants.LOCATION_DATA_EXTRA);
ResultReceiver mReceiver = intent.getParcelableExtra(
LocationConstants.RECEIVER);
try {
for (int i = 0; i < locationsList.size(); i++) {
GitHubUserLocationDataEntry entry = locationsList.get(i);
List<Address> addressList = geocoder.getFromLocationName(entry.getLocation(),1);
if (!addressList.isEmpty()) {
Address address = addressList.get(0);
entry.setLatitude(address.getLatitude());
entry.setLongitude(address.getLongitude());
}
}
} catch (IOException ioException) {
// Catch network or other I/O problems.
errorMessage = getString(R.string.service_not_available);
Log.e(TAG,errorMessage,ioException);
} catch (IllegalArgumentException illegalArgumentException) {
// Catch invalid latitude or longitude values.
errorMessage = getString(R.string.invalid_lat_long_used);
Log.e(TAG,illegalArgumentException);
}
Bundle bundle = new Bundle();
bundle.putParcelableArrayList(LocationConstants.LOCATION_DATA_EXTRA,locationsList);
mReceiver.send(0,bundle);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。