My application basically backup the SMS and MMS to cloud server. I used below URI to retrieve data from database.
SMS- Uri uri = Uri.parse("content://sms/");
MMS-Uri uri = Uri.parse("content://mms/");
Few days back while testing my app i noticed some messages(SMS & MMS) are missing while retrieving from SQLite. After doing some research i found that those are RCS (Rich Communication Services) messages. Now my challenge is to read RCS messages(SMS & MMS).
Is there any way to read RCS (Rich Communication Services) messages in Android?
What URI i need to use for read RCS (Rich Communication Services) messages?
Thanks in advance.
EDIT: It seems like the API won’t make it after all. Work is still happening to it apparently: https://android-review.googlesource.com/q/RCS+(status:open+OR+status:merged). But it won’t be for third-party developers.
According to this (https://9to5google.com/2019/02/22/android-q-rcs-api-delay/), now there will be no developer-accessible API for RCS messages until Android R at the earliest.
There isn’t a way (short of some vendor-specific API) at the moment, but support for programatically interfacing with RCS is underway if the code commits are any indication of the direction Android is going… https://android-review.googlesource.com/c/platform/frameworks/base/+/849669
The relevant classes are still being implemented, but it looks like you’ll be relying on these (tentatively):
RcsParticipant
RcsThread
Rcs1To1Thread (extends RcsThread)
RcsGroupThread (extends RcsThread)
RcsMessage
RcsIncomingMessage (extends RcsMessage)
RcsOutgoingMessage (extends RcsMessage)
RcsPart
RcsFileTransferPart (extends RcsPart)
RcsLocationPart (extends RcsPart)
RcsMultiMediaPart (extends RcsPart)
RcsTextPart (extends RcsPart)
This code is telling:
class RcsThreadQueryHelper {
static final String ASCENDING = "ASCENDING";
static final String DESCENDING = "DESCENDING";
static final String THREAD_ID = "_id";
static final Uri THREADS_URI = Uri.parse("content://rcs/thread");
static final Uri PARTICIPANTS_URI = Uri.parse("content://rcs/participant");
static final String[] THREAD_PROJECTION = new String[]{THREAD_ID};
static String buildWhereClause(RcsThreadQueryParameters queryParameters) {
// TODO - implement
return null;
}
}
Related
I am trying to implement this in android.
https://github.com/googleworkspace/java-samples/blob/master/gmail/quickstart/src/main/java/GmailQuickstart.java
few questions :
private static final String APPLICATION_NAME = ... is this the android app name?
what is the alternative for this in android :
private static final String TOKENS_DIRECTORY_PATH = "tokens";
full description and working solution is here
Use Gmail api for send mail via Android app
basically you need to change few things:
browser Call (within the auth function) to intent.
and remove all UI calls from do in background process.
With Nearby Connections, each device has an endpointId, something similar to zkHk.
Getting the endpointId of others is trivial since it is returned by the API when scanning or connecting to other devices.
I must miss something, but I cannot find a way to get my own endpointId (apart implementing a mechanism where a connected peer echoes my id). It can be useful for some protocols where I want to follow what is sent to who.
The only thing I found is getLocalEndpointName but it returns my name, not my id. Even though it seems the C++ version of Nearby have it!
Do you have some ideas for Java/Kotlin? I specifically seek to get the endpointId, and not use alternatives like using a kind of GUID in the localendpoint name as a replacement.
Edit: Some example of usage
1) For instance, it can be interesting to implement some network mesh protocols. Several devices are interconnected making a global network, and each device add its endpointId in the incoming payload before sending it again, so others can check if they should send the payload to a device that already has it.
2) I may also want to specifically send a packet from device A to C through B acting as a relay, and add some "from: A" and "to: C" field in the payload so the network would know how to route the data and avoid some retransmission cycles. It is simpler to do that with endpointId since each device has a list of endpointId to which it is connected.
3) It can also be interesting for debug purpose. If I do some tests with a phone connected to several others (e.g. star network), it is easier to know from which phone a new piece of data is coming, all the more if I want to use name for another purpose.
Note: all of that could be done differently (e.g. use some unique identifier for the "name" of the devices and check that instead of the endpointId) but it seems a little cumbersome. All the more since endpointId guarantee a kind of unicity, whereas I must enforce it for the name. Moreover there isn't lots of information I can have on another device before exchanging data (only endpointId and name), so I feel I remove my last metadata slot if I use name as a substitute for endpointId.
As of today, you can't get your own endpoint id. We didn't see a reason you'd need it. Can you give a more detailed example of an algorithm where you need to know your own id?
i think you want to get your endpointId and sent its to other devices to know you again ?
if yes
let's think like that :
other devices will get your EndpointID and save it every time you connect to them
1)you have an Arrylist<EndPointObject> listOfUsers where EndPointObject it's an Object contain informations about Connected Endpoint Device (you create this class).
we w'ill use this Arry list to save recieved Endpoint informations
2)you need to make EndPointObject class Serializable by implements Serializable,you are doing that to make it able to be converted to Byte[] and send it in payload
public class EndPointObject implements Serializable
{
String endpointId ;
.
.
.
}
3)this is the Converting class add it to your project
public class SerializeHelperForPayLoad {
public static byte[] serialize(Object object) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
// transform object to stream and then to a byte array
objectOutputStream.writeObject(object);
objectOutputStream.flush();
objectOutputStream.close();
return byteArrayOutputStream.toByteArray();
}
public static Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException{
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
return objectInputStream.readObject();
}
}
4) now the strategy is every time you connect to an endpoint Device you will exchange yours EndpointObject informations,so in payloadcallback
PayloadCallback mPayloadCallback =
new PayloadCallback() {
#Override
public void onPayloadReceived(String endpointId, Payload payload) {
if (payload.getType() == Payload.Type.BYTES) {
try{
onDataReceived(endpointId, SerializeHelperForPayLoad.deserialize(payload.asBytes()));
} catch (IOException | ClassNotFoundException e) { e.getMessage(); }
}
}
// onData recieved void
void onDataReceived(String endpointId, Object object) {
// do something with your Object
EndPointObject recieved_user_info = new EndPointObject();
if (object.getClass() == EndPointObject.class){
//casting
recieved_user_info = (EndPointObject) object;
//now add his end pointid to his information
recieved_user_info.setEndpointId(endpointId);
listOfUsers.add(recieved_user_info);
}
}
i'm very new in nearby technology ,but i hope that's helpful ,
by this way you can ask other end endpoint to send you your own endpointid every time
I trying to create an app that can detect a usb devices. The android device act like a Host, and I now only need to read data of attached devices.
I import android.hardware.usb.UsbDevice
All work fine, but the problem is with any usbDevice methods. I can read the usbDevice.getDeviceName() method but I can't use for example getVersion(), whY?
He say me that cannos resolve this method. Also about other methods.
private String readDevice(UsbDevice device) {
StringBuilder sb = new StringBuilder();
String a = device.getDeviceName(); //work
String b = device.getVersion(); //doesn't work
}
You need to read This Link
It's included in API 23.
String versionStr = UsbDevice.getVersion();
Or you may help from This Link
I'm wondering if it's feasible to list out all Twitter clients that are installed into a phone. At first, I thought this could be done by matching the package name with "Twitter". But most of the Twitter clients on Android don't have 'Twitter' name in their package name.
We can fetch application list with specific permissions but that doesn't going to help me. Fetching applications with certain custom intents probably not going to help as well, and I still have to find a way to get a list of applications that handle a custom Intent.
It doesn't seem feasible but there must be some way that could at least put me close to want I want. Anyone would like to shed some light on it?
I don't know if there is some kind of method to get "twitter client" (how we define Twitter client?).
You can fetch a list of names (the twitter clients you know) on the packages installed on devices.
final List<PackageInfo> apps = context.getPackageManager().getInstalledPackages(0);
final String separator = ";";
final String separatorVersion = "-";
//Log.i("Package list", "num:+"+apps.size());
for (PackageInfo infoApp : apps) {
for (TwitterClient tr : mapTwitterClient.values()) {
if (infoApp.packageName.contains(tr.getPackageName()) ) { //it's a Twitter client this package?
if (!twitterClients.equals("")) {
twittersClients += separator;
}
twitterClients += tr.getCommonName()+separatorVersion+infoApp.versionName;
}
}
}
You need to create the class TwitterClient which just have 2 properties(packageName and commonName) and his getters/setters.
And fill map with all TwitterClient you know (Ex: new TwitterClient("com.twitter.android","Twitter official") );
private static final HashMap<String, TwitterClient> mapTwitterClient
This method it's hard process so use smartly.
I wish to achieve a SMS loopback, i.e. to send and receive SMS from the same application. In order to do so, I have created a class that extends BroadcastReciever, implemented the onReceive() method, and declared the relevant permissions.
I verified the implementation by sending a SMS using telnet.
I want to automate the telnet process, i.e. having the application test itself by sending the SMS. In order to do so, I invoke the following method in the main activity, but the BroadcastReceiver is never called:
private final void sendSMS() {
final TelephonyManager telMgr = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
final int len = telMgr.getLine1Number().length();
final String phoneNum = telMgr.getLine1Number().substring(len - 4, len);
final String msg = "msg";
SmsManager.getDefault().sendTextMessage(phoneNum, null, msg, null, null);
}
Any clue what is wrong...?
UPDATE: Note that the code above is intended for the emulator.
Not sure if I understand you question right, but are you trying send an SMS from the emulator to itself? As far as I know, that is not possible. Just load up another emulator, and send messages between them.
Since telnet commands work, your BroadcastReceiver is probably correctly implemented, but you should probably attach the code for it anyways... Its hard to troubleshoot code you can't see :)