问题
I have a RecyclerView list of CardViews that hold a small amount of user data. The data is saved to the app's SQLite database. I would like to send a CardView's data from one app user to another via SMS/MMS. The SMS is sent when the user clicks the share icon on the CardView. Then when the receiving user clicks on the image in the SMS text, the app would be opened/brought to the forefront, the data would be saved in the recipient's SQLite database and then the RecyclerView list would be shown with a new CardView from the data that was passed via SMS.
I am able to attach the image to the SMS text message and am able to send and receive the image and the message:
How can I attach the data to the image so that when it is clicked on by the user it opens the app, saves the data and then shows the new CardView in the RecyclerView list? Would an SVG image file work in this case because links can be embedded within the SVG? Can I save the data in a JSONObject and attach it to the SVG and then when the user clicks on the image the JSON can be parsed in the app, saved to the database and then the updated UI for the RecyclerView list of CardViews can be shown? Would an AppWidgetProvider and RemoteViews work here? Or is there another way to attach data to the image that can be passed to the receiving app once the user confirms their acceptance by clicking on the image?
MainActivity
...
public void onShareIconClick(View view, Card cardFromShareIcon, int clickPos) {
final Intent smsIntent = new Intent(Intent.ACTION_SEND);
String phoneMsg = "here's a card for you:";
smsIntent.putExtra(Intent.EXTRA_TEXT, phoneMsg);
smsIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
smsIntent.setDataAndType(shareUri,getContentResolver().getType(shareUri));
smsIntent.putExtra(Intent.EXTRA_STREAM,shareUri);
try {
if (smsIntent.resolveActivity(getPackageManager()) != null) {
startActivity(smsIntent);
}
} catch (Exception e) {
Log.w(TAG2, "Could not open Text Messenger app", e);
// Inform user
Toast.makeText(this,
"Could not open your Text Messaging app.",
Toast.LENGTH_LONG).show();
}
}
回答1:
I'm not sure if its possible what you are looking for, but I think your best approach would be to use firebase dynamic links.
来源:https://stackoverflow.com/questions/62239517/android-deliver-plain-text-data-to-another-app-user-with-clickable-image-via-sm