how to open different activities when receiving notification from parse - android-activity

I have different categories in my app such as news,weather,sports and technology,I use parse to receive notification ,but i want the notification to be customized in which once a notification regarding news is received it should open news activity,if notification regarding technology is received it should open technology activity.
I don't want custom push receiver,i tried lots of examples but i can't get it.any ideas thanks in advance

First you need to create a custom class that extends ParsePushBroadcastReceiver.
and in that class you Override onPushOpen method:
public class ParsePushCustomReceiver extends ParsePushBroadcastReceiver {
protected static String pushTitle="";
#Override
protected void onPushOpen(Context context, Intent intent) {
super.onPushOpen(context, intent);
pushTitle="";
try {
Bundle extras = intent.getExtras();
if (extras != null) {
String jsonData = extras.getString("com.parse.Data");
JSONObject json;
json = new JSONObject(jsonData);
pushTitle = json.getString("title");
String pushContent = json.getString("alert");
//intent to your activity
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Now when you have the title and the content of the push you can direct to the activity that you want to go...
You need to define your custom ParsePushBroadcastReceiver as reciever in AndroidManifest.xml:
<!-- Parse PushService-->
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.appname.appname.ParsePushCustomReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.appname.appname" />
</intent-filter>
</receiver>

Related

Problems wit redirect URI Flutter

I tried, to authenticate my App at Spotify, via FlutterWebAuth2, but I always, get a "Illegal redirect Uri" Error.
My authentication function
try {
var redirectURI = 'beatrunner:/';
final result = await FlutterWebAuth2.authenticate(
url:
"https://accounts.spotify.com/authorize?client_id=xxxx&redirect_uri= $redirectURI&scope=user-read-currently-playing&response_type=token&state=123",
callbackUrlScheme: "beatrunner",
);
} catch (e) {
print(e);
}
}
My Android Manifest file
<activity android:name="com.linusu.flutter_web_auth2.CallbackActivity" android:exported="true">
<intent-filter android:label="flutter_web_auth2">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="beatrunner" />
</intent-filter>
</activity>
I tried to solve my Problem using this articlehttps://stackoverflow.com/questions/58244209/flutter-oauth2-problems-with-redirect-uri, but I still get a error message.

Deep Link for Android with .Net Maui error - Unable to instantiate activity ComponentInfo MainActivity

I'm trying to get deep links to work for my maui android app but when I click to open the link with the app I get this error:
Java.Lang.RuntimeException: 'Unable to instantiate activity ComponentInfo{app.mydomain/MyApp.Client.MAUI.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class "MyApp.Client.MAUI.MainActivity"
on path: DexPathList[[zip file "/data/app/~~0C9vYHAHNOr9CaB4f63clQ==/app.mydomain-YYQ6ZPc3-KSVnF8_VcuQVQ==/base.apk"],
nativeLibraryDirectories=[/data/app/~~0C9vYHAHNOr9CaB4f63clQ==/app.mydomain-YYQ6ZPc3-KSVnF8_VcuQVQ==/lib/arm64,
/data/app/~~0C9vYHAHNOr9CaB4f63clQ==/app.mydomain-YYQ6ZPc3-KSVnF8_VcuQVQ==/base.apk!/lib/arm64-v8a, /system/lib64,
/system_ext/lib64]]'
My MainActivity.cs looks like this
namespace MyApp.Client.MAUI
{
[Activity(Theme = "#style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "https", DataHost = "mydomain.app", DataPathPattern = "/.*", AutoVerify = true)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
protected override void OnResume()
{
base.OnResume();
Platform.OnResume(this);
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
var data = intent.DataString;
if (intent.Action != Intent.ActionView) return;
if (string.IsNullOrWhiteSpace(data)) return;
var path = data.Replace(#"https://mydomain.app", "");
//todo - handle path
StartActivity(typeof(MainActivity));
}
}
The intent filter in the AndroidManifest.xml is like so:
<activity android:name="MyApp.Client.MAUI.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="mydomain.app" android:pathPattern="/.*" />
</intent-filter>
</activity>
I could reproduce your problem.
And I can resolve this problem by adding tag <application> inside of AndroidManifest.xml.
You can refer to the full code of AndroidManifest.xml on my side:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-permission android:name="android.permission.INTERNET" />
      <application android:allowBackup="true" android:supportsRtl="true" android:theme="#style/AppTheme" android:name="android.app.Application" android:debuggable="true" android:extractNativeLibs="true">
            <activity android:name="MauiBlazorApp.MainActivity" android:exported="true">
                  <intent-filter>
                        <action android:name="android.intent.action.VIEW" />
                        <category android:name="android.intent.category.DEFAULT" />
                        <category android:name="android.intent.category.BROWSABLE" />
                        <data android:scheme="https" android:host="mydomain.app" android:pathPattern="/.*" />
                  </intent-filter>
            </activity>
            
      </application>
</manifest>
Note: Remember to change the value of android:name(YourAppName) of your activity to yours.
<application android:name="YourAppName.MainActivity">

Im trying to get link after deep linking rotate

im opening app from link. but i cant listen my link after opened app. i need to get a token from link.
AndroidManifest.xml:
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="myappname.page.link" />
</intent-filter>
and my listener uni_links like that:
getLinksStream().listen((link) async {
print("urigirdi");
try {
var _latestUri;
if (link != null) _latestUri = Uri.parse(link);
setState(() {
sourceLink = link!.split("/")[3];
print("link");
linkToken = sourceLink.split("?")[2];
linkPath = sourceLink.split("?")[0];
print(linkPath);
print(linkToken);
});
} on FormatException {
print("--- A link got here but was invalid");
}
});
i need some help. can anybody help me ? thanks for everything...

share list of Images from gallery and any type of files from outside our application:

I'm trying to share a list of images from the gallery into my app to use it recycler view
or any thing else
<activity
android:icon="#mipmap/ic_launcher"
android:name=".MainActivity"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
that works:-
1-specify these lines on the manifest
<activity
android:icon="#mipmap/ic_launcher"
android:name=".MainActivity"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<data android:mimeType="*/*"/>
<data android:mimeType="image/jpeg" />
<data android:mimeType="image/png" />
<data android:mimeType="image/jpg" />
</intent-filter>
</activity>
2-Second get the action that opened your intent and check if its the one we registered for the activity and then the data is received as ArrayList of Uri
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
Bundle extras = intent.getExtras();
if (extras.containsKey(Intent.EXTRA_STREAM)) {
ArrayList<Uri> urisArrayList = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
urisArrayList.forEach(i-> Log.d(TAG, "onCreate: "+i.toString()));
}
}}

How can I create a project in Android Studio to function default SMS app

Continuation of the previous query, see: SMS Receiver for AND API 19 and higher
I need to make the application run in the background and I could have it after installing the set as a default as shown here: http://android-developers.blogspot.cz/2013/10/getting-your-sms-apps-ready-for-kitkat.html
So I asked how to create a project to display a list of the "Super Duper SMS," which finally set as default.
The whole program must running as a service, without the need any screen for basic functions Receive SMS and should be registered in the core android
Thanks for any advice
I am tried with this code it help me...
manifests.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newsmsapp">
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/smsicon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.example.newsmsapp.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<activity android:name="com.example.newsmsapp.ComposeSMS">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="sms"/>
<data android:scheme="smsto"/>
<data android:scheme="mms"/>
<data android:scheme="mmsto"/>
</intent-filter>
</activity>
<receiver
android:name="com.example.newsmsapp.SMSReceiver"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
</intent-filter>
</receiver>
<activity
android:name="com.example.newsmsapp.NotificationView"
android:label="#string/title_activity_notification_view"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<receiver android:name="com.example.newsmsapp.MMSReceiver" android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER"/>
<data android:mimeType="application/vnd.wap.mms-message"/>
</intent-filter>
</receiver>
<service android:name="com.example.newsmsapp.HandlessSMSSendService"
android:exported="true"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE">
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE"/>
<data android:scheme="sms"/>
<data android:scheme="smsto"/>
<data android:scheme="mms"/>
<data android:scheme="mmsto"/>
</intent-filter>
</service>
</application>
then create 4 file for smsReader,mmsReader,ComposeSMS,HeadlessSMSservice
smsReader.java
public class SMSReceiver extends BroadcastReceiver {
Notification notification;//=new Notification(R.drawable.icon,"New Message",System.currentTimeMillis());
NotificationManager notificationmaneger;
String SMSmsg;
public SMSReceiver() {
}
public static final String SMS_BUNDLE = "pdus";
#Override
public void onReceive(Context context, Intent intent) {
Bundle intentExtras = intent.getExtras();
if (intentExtras != null) {
Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
String smsMessageStr = "";
for (int i = 0; i < sms.length; ++i) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);
String smsBody = smsMessage.getMessageBody().toString();
String address = smsMessage.getOriginatingAddress();
smsMessageStr += "SMS From: " + address + "\n";
smsMessageStr += smsBody + "\n";
builder.setAutoCancel(true);
// builder.setTicker("this is ticker text");
builder.setContentTitle("New Messge");
builder.setContentText(SMSmsg);
builder.setSmallIcon(R.drawable.smsicon);
builder.setColor(context.getResources().getColor(R.color.colorAccent));
builder.setContentIntent(pendingIntent);
builder.setOngoing(true);
// builder.setSubText("You have pending tax"); //API level 16
//builder.setNumber(100);
builder.build();
}
SMSmsg=smsMessageStr;
}
}
mmsReader.java
public class MMSReceiver extends BroadcastReceiver
{
public MMSReceiver()
{
}
#Override
public void onReceive(Context context, Intent intent) {
}
}
ComposeSMS.java
public class ComposeSMS extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
}
}
HeadlessSMSservices.java
public class HandlessSMSSendService extends Service {
#Nullable
#Override
public IBinder onBind(Intent intent) {
return null;
}
}
if u want to see SMS then add listview in composeSMS.java and bind received data from sms table to listview adapter.