I'm trying to use GCM to receive messages from our server when the user is not in the app.
The porblem is that the GcmListenerService doesn't seem to work whilst the registeration works just fine. Our server should be working just fine since we receive confirmation from the GCM server every time we send something from our server to GCM.
This is my manifest (only GCM section)
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="false"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="my.package.package"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="my.package.package"/>
</intent-filter>
</receiver>
<service
android:name=".services.MyGcmListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<service
android:name=".services.MyGcmRegisterationService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
and this is the simplified onMessageReceived
#Override
public void onMessageReceived(String from, Bundle data)
{
saveDataToDatabase(data);
dataReceivedNotification();
}
I managed to resolve this.
I had
<uses-permission android:name="com.google.android.c2dm.permission.SEND" />
Twice in the Android Manifest and I was missing
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
Related
I want to add two classes in accessibility service
I have tried this and its showing some errors of tag
<service
android:name=".ClassGen1",".ClassGen2"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:persistent="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
mistake in your code is writing class names with comma .
android:name=".ClassGen1",".ClassGen2"
Value of name attribute cannot be written with comma in android . You should declare them separately in different service tags . Like as below
<service
android:name=".ClassGen1"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:persistent="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
<service
android:name=".ClassGen2"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:persistent="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
i am using Accessibility Service to click USSD dialogbox but i want some delay like 3 sec after Dialogbox appered
here is my code
<receiver android:name=".Messagereciver"
android:exported ="true">
<intent-filter android:priority="3000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<service
android:name=".USSDService"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter android:priority="3000" >
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data android:name="android.accessibilityservice"
android:resource="#xml/config_service" />
</service>
i have tried change android:priority 3000 but still same
even in android:notificationTimeout="3000" in config_service
When using App Links, the receiver app (EX. Whatsapp) is paused, and your application's activity is opened on top of the receiver app.
For example, if you open your link from a WhatsApp's chat page, the new activity isn't opened from your app (The WhatsApp's task in recent apps includes your app), while your app isn't in the recent task.
But what if I want to open my application in a new task? Separate from the receiver app?
This is my Manifest file of the activity opened from the App Link:
<activity
android:name=".Activitys.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:autoVerify="true"
android:label="#string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="eventtk.uae-dc.com"
android:pathPrefix="/product/"
android:scheme="https" />
</intent-filter>
</activity>
Is there a thing I should add to the IntentFilter?
Not sure if I understood correctly what you would like to achieve, but you can try
to add
android:launchMode="singleTask"
to your activity definition.
More information here:
https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
I am trying to use gcm to push notifications on android devices. So far I have registered with gcm and sent my back-end the necessary information to make a post request to the gcm severs which builds a 200 response. All the steps have come together except the client side receiving the message. I don't get the message. Displayed here is my gcm listener class:
import com.google.android.gms.gcm.GcmListenerService;
public class MyGcmListenerService extends GcmListenerService {
public static final int MESSAGE_NOTIFICATION_ID = 435345;
private static final String TAG = "MyGcmListenerService";
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
sendNotification(from,message);
}
private void sendNotification(String title, String body) {
Context context = getBaseContext();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title)
.setContentText(body);
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build());
}
}
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<recieve android:name = ".GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.example.caesar.gcm" />
</intent-filter>
</recieve>
</application>
// new manifest file
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.caesar.gcm.permission.C2D_MESSAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<reciever
android:name = "com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.example.caesar.gcm" />
</intent-filter>
</reciever>
<service
android:name="com.example.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.example.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
</application>
Actually looking at this further it looks like you haven't setup the receiver correctly. Seems you need to include at least.
<service
android:name="com.example.MyGcmListenerService "
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
And for the rest just follow that link.
You have to put your resgistration intent service at the end of yout Manifest file. Like this example:
<service
android:name="com.example.gcm.RegistrationIntentService"
android:exported="false">
</service>
Hope that help you, more information, you can visit this link and you can view an example of RegistrationIntentService here.
I am trying to receive the sending whatsapp intent when sharing the conversation via email.I can't make my application appear in the possible applications to share.I need information on how to properly configure my androidmanifest and receive the attachment * .txt.Thanks and I hope I have expressed myself well.
You need an <intent-filter> in your activity that will be handling the email:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.SENDTO"/>
<data android:scheme="mailto"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
This is what the email app uses.
Source: android intent-filter to listen for sent email addresses?
Your application doesn't appear in the chooser because Whatsapp has whitelisted only some packages for the email applications.
For more information, see this answer