receiver

Run service on incoming SMS in android Oreo

末鹿安然 提交于 2019-11-29 10:46:13
I'm developing an app which needs to run some code (Networking) whenever an SMS is received. In API 25 and lower it's fine, I register an implicit receiver in Manifest file and start my service in the specified class which extended BroadcastReceiver . In API 26 however you cannot register android.provider.Telephony.SMS_RECEIVED in a receiver since it won't work. From Android documentation: Note: If your app targets API level 26 or higher, you cannot use the manifest to declare a receiver for implicit broadcasts (broadcasts that do not target your app specifically), except for a few implicit

Sending SMS using Intent does not add recipients on some devices

给你一囗甜甜゛ 提交于 2019-11-29 07:57:21
I send SMS using code below: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("smsto:" + phoneNumber)); intent.putExtra("address", phoneNumber); intent.putExtra("sms_body", messageBody); intent.setType("vnd.android-dir/mms-sms"); context.startActivity(intent); I added both Uri with smsto: and address String extra to Intent. It works on most devices, but on some - it doesn't. One of the devices is SE XPERIA Mini. What else can be added when sending SMS to make sure recipient is set in SMS App? I looked into Intent source and it seems that setting intent type removes data and setting

Android DownloadManager get filename

点点圈 提交于 2019-11-28 20:24:34
In my app you can download some files. I used the Android DownloadManager class for downloading. After the download is completed, it should show me a message that the file was downloaded. The problem is, there could be 2,3 or 4 downloads at the same time. My BroadcastReceiver code looks like this: receiver_complete = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE) ){ Toast.makeText(MainActivity.this, MainActivity.this.getString(R.string.download_finished,

Django: When to customize save vs using post-save signal

99封情书 提交于 2019-11-28 08:16:05
I have a series of tests and cases in a database. Whenever a test is obsoleted, it gets end dated, and any sub-cases of that test should also be end dated. I see two ways to accomplish this: 1) Modify the save function to end date sub-cases. 2) Create a receiver which listens for Test models being saved, and then end dates their sub-cases. Any reason to use one other than the other? Edit: I see this blog post suggests to use the save method whenever you check given values of the model. Since I'm checking the end_date, maybe that suggests I should use a custom save? Edit2 : Also, for the record

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. file init

六月ゝ 毕业季﹏ 提交于 2019-11-28 05:08:50
问题 django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Exception appeared when I added: import signals in init .py file (apps/application/init.py) from models import Review in signals.py file (apps/application/signals.py) I want to send an http request when there is an insert in the model Review. So I need to import Review model (in the __init.py__ file) to execute the following code: @receiver (pre_save, sender = Review) def my_handler (sender, ** kwargs): .... 回答1: In the

C++ DGRAM socket get the RECEIVER address

跟風遠走 提交于 2019-11-28 02:09:30
In C++, how can I get the receiver address of the UDP packet which I have received using recvfrom. I know that it should be the same host on which I am receiving the packet, but I need to extract it from the received packet, in order to verify something. How can I do this? I found that one way of doing this is: int r = getsockopt(receiver_sock, SOL_IP, SO_ORIGINAL_DST, (struct sockaddr *) &sender_addr, (socklen_t *)&addr_len);` But I get the error: error: ‘SO_ORIGINAL_DST’ was not declared in this scope I am using the appropriate headers #include <sys/types.h> #include <sys/socket.h> #include

Sending SMS using Intent does not add recipients on some devices

倖福魔咒の 提交于 2019-11-27 18:52:20
问题 I send SMS using code below: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("smsto:" + phoneNumber)); intent.putExtra("address", phoneNumber); intent.putExtra("sms_body", messageBody); intent.setType("vnd.android-dir/mms-sms"); context.startActivity(intent); I added both Uri with smsto: and address String extra to Intent. It works on most devices, but on some - it doesn't. One of the devices is SE XPERIA Mini. What else can be added when sending SMS to make sure recipient is set in

ViewFlipper : Receiver not registered

南笙酒味 提交于 2019-11-27 06:06:15
问题 In my app sometimes I receive this error : java.lang.IllegalArgumentException: Receiver not registered: android.widget.ViewFlipper$1@4806a4a8 at android.app.ActivityThread$PackageInfo.forgetReceiverDispatcher(ActivityThread.java:667) at android.app.ApplicationContext.unregisterReceiver(ApplicationContext.java:840) at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:321) at android.widget.ViewFlipper.onDetachedFromWindow(ViewFlipper.java:104) at android.view.View

Django: When to customize save vs using post-save signal

笑着哭i 提交于 2019-11-27 01:49:00
问题 I have a series of tests and cases in a database. Whenever a test is obsoleted, it gets end dated, and any sub-cases of that test should also be end dated. I see two ways to accomplish this: 1) Modify the save function to end date sub-cases. 2) Create a receiver which listens for Test models being saved, and then end dates their sub-cases. Any reason to use one other than the other? Edit: I see this blog post suggests to use the save method whenever you check given values of the model. Since

C++ DGRAM socket get the RECEIVER address

ⅰ亾dé卋堺 提交于 2019-11-26 22:07:22
问题 In C++, how can I get the receiver address of the UDP packet which I have received using recvfrom. I know that it should be the same host on which I am receiving the packet, but I need to extract it from the received packet, in order to verify something. How can I do this? I found that one way of doing this is: int r = getsockopt(receiver_sock, SOL_IP, SO_ORIGINAL_DST, (struct sockaddr *) &sender_addr, (socklen_t *)&addr_len);` But I get the error: error: ‘SO_ORIGINAL_DST’ was not declared in