Android parse.com Can't receive push notification - android

I can't receive push notifications, using parse.com service.
I used a quick guide trying to solve my problem. I was trying to use channel this specified name and "" as a channel name. Also i found Cannot receive push notifications in Android with trigger.io and parse.com
I succeed to send object to parse.com, and to subscribe for notifications (at least I can see my app in DataBrowser on parse.com)
public class ParseStarterProjectActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PushService.subscribe(this, "push", TestParse.class);
PushService.setDefaultPushCallback(this, TestParse.class);
}
}
public class ParseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, my_id, my_client_key);
}
}
public class TestParse extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.parse);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.parse.starter"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="ParseApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<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>
<activity
android:name=".ParseStarterProjectActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TestParse"
android:label="#string/app_name" />
</application>
</manifest>
Recently I've noticed LogCat errors:
02-21 18:17:45.381: ERROR/Trace(8952): error opening trace file: No such file or directory (2)
02-21 18:17:48.534: ERROR/com.parse.PushService(8888): unknown host
I really want to receive notifications. What am I doing wrong?

Parse employee here. In order to handle increased load on our push service, we increased the number of machines serving push.parse.com. Some ISPs started having issues when DNS resolution returned this many servers. Last Friday afternoon, we launched a custom DNS server which works around these issues with 3rd party DNS resolution. This should no longer be an issue.

Related

Android onCreate not firing on new activity

Hi there I am trying to execute some code when I change to the next activity, but it does not seem to work. The Previous activity is a login page if the user is already logged in it goes straight to the new activity. But the onCreate does not seem to fire.
Main Activity
public class MainActivity extends AppCompatActivity {
private View mMainView;
private Meteor mMeteor;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("ACTIVITY");
Log.d("SimpleActivity","OnCreate Started");
if(MeteorSingleton.getInstance().isConnected()){
Log.d("Connection", "Connected");
}else{
Log.d("Connection", "Not Connected");
}
}
........
The strange thing is the setTitle works but none of the logs.
Here is some code from the previous login in page.
#Override
public void onConnect(boolean signedInAutomatically) {
Log.i("Connection", "Connected to host server");
if (mMeteor.isLoggedIn()) {
openMainScreen(mLoginFormView);
}
}
public void openMainScreen(View view) {
Intent dashboard = new Intent(getApplicationContext(), MainActivity.class);
startActivity(dashboard);
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="system.carproject.adam.ams">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="Activity">
<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.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps"></activity>
</application>
</manifest>
If someone could educate me on this would be great. Can seem to figure it out.
Thanks
You have created two LAUNCHER Activities and that's created two App Icon in your Device so if you think its open directly MainActvity then its possible if you click on second app icon in your device for same application . check your device .
first remove LAUNCHER mode from MainActvity in Android Manifest and then you have to add manual check in your login Activity onCreate() for login status and then startActvity() MainActivty if login status is true.
try removing the intent filter tag from activity tag of MainActivity in Manifest:-
<activity android:name=".MainActivity"
android:label="Activity"> </activity>

Application stops receiving GCM notifications after inactivity (does android force applications into stopped state?)

I have an application that correctly receives notifications, even when the application has been killed by swiping. However, after a longer period of inactivity (e.g. application not used for ~2 weeks) the notifications stop getting delivered. The behavior is consistent with applications that have been force stopped (http://developer.android.com/about/versions/android-3.1.html#launchcontrols). However, I am confident that the application has not been force stopped.
To elaborate, the device receives the GCM message and the intent is triggered, but the application is not available to process it. See log excerpt below for details on what happens when notification is sent.
03-30 19:43:24.596: I/GCM(4931): GCM message com.company.application 0:1459359805552536%60ff11d7f9fd7ecd
03-30 19:43:24.606: W/GCM-DMM(4931): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.company.application (has extras) }
Does android sometimes force idle applications into a stopped state? Is there reason for this to occur other than a stopped state?
If it matters, notifications are implemented using Urban Airship, but I had similiar problems before migrating from Parse.
Code excerpts below.
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.application"
android:versionCode="27"
android:versionName="1.31">
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.company.application.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.company.application.permission.C2D_MESSAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<application
android:name=".MyApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".Main"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
<activity android:name=".ParseDeepLinkActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<!-- Handles any vnd.company.application://deeplink URI's -->
<data android:scheme="vnd.company.application" android:host="deeplink" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
</application>
</manifest>
Application
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
UAirship.takeOff(this, new UAirship.OnReadyCallback() {
#Override
public void onAirshipReady(UAirship airship) {
// Enable user notifications
airship.getPushManager().setUserNotificationsEnabled(true);
}
});
}
}
Are you implementing a WakeLock object? Do you set a keepalive value for your GCM messages? I suggest you start by checking both points or post some more code / details so we can understand the whole scope :)

phonegap app loads first page upon screen orientation change

i am developing an android app using phonegap. i have multiple pages in the app and a single activity. whenever i change the orientation of the device, no matter which page i am on, the app loads the first page which is shown when the app is launched. i assumed it was because i had not overriden the onResume() method in the activity, but even that failed to solve the problem.
EDIT: This issue does not arise if the app is paused and the resumed.
My activity:
public class MainScreen extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/landing.html");
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
}
EDIT: Added Manifest file
My Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.code"
android:versionCode="5"
android:versionName="1.4" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.miniorange.authenticator.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.miniorange.authenticator.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.miniorange.authenticator.MainActivity"
android:label="#string/app_name" >
</activity>
<activity android:name="com.miniorange.authenticator.MainScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.plugin.gcm.PushHandlerActivity"/>
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" 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.me.code" />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />
</application>
</manifest>
what may be the solution to this problem?
sorry ... ( answering it late :D )
I had this problem with my app :
When I change the orientation, activity reloads ...
And I found this solution :
add this attribute to your <activity> tags :
android:configChanges="orientation"
suggestion ... use this insted (better) :
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
==========================================
information about solution :
what is the reason .. (?)
It'll say to application that you want to handle this changes (orientation, keyboardHidden, keyboard, screenSize, locale, etc.) yourself.

Android Broadcast receiver works on emulator but not on device

So here is the setup.. I have two apps AppReceiver.apk and AppClient.apk. AppReceiver project has just one receiver and no other activity and AppClient just sends the broadcast message. This works in my emulator with Android 4.0 api level 14 on my mac but not in windows or on actual device.
Code for AppReceiver.apk
*MyReceiver.java*
public class MyReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context arg0, Intent arg1) {
Log.d("MyReceiver", "Got Message");
}
}
Manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appreceiver"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver android:name="MyReceiver">
<intent-filter>
<action android:name="com.appreceiver.CUSTOM_INTENT"></action>
</intent-filter>
</receiver>
</application>
</manifest>
Code for AppClient
MainActivity.java
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button sendButton = (Button)findViewById(R.id.sendbroadcastButton);
sendButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent();
intent.setAction("com.appreceiver.CUSTOM_INTENT");
sendBroadcast(intent);
}
});
}
Manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appclient"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.appclient.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>
</application>
</manifest>
So here is what is happening when I click on the sendbroadcast button in my emulator that is running in Mac then I see the log message Log.d("MyReceiver", "Got Message"); in my logcat meaning it is working as expected. I can click more than once and it works as expected.
However when I installed it on the device I do not see the message in logcat (I made sure I am reading the logcat from device) Also I have another windows laptop and on that one it won't show this message on the emulator either. So I am not sure what is going on? Any pointers?
So I confirmed that I will have to start AppReceiver.apk at least once after install and this is a new requirement or safety thing after Android 3.1 as they want user to explicitly start an app in order to user its broadcast receiver.
Since I did not wanted any GUI thing, the way I did is just wrote an activity which is not calling any view and defined the theme as android:theme="#android:style/Theme.NoDisplay" in manifest so the user won't notice after install that the app has already started and the receiver is also available. Thanks #Nitin Sethi for pointing me in the right direction.
public class MyActivity extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
}
Here is how the new manifest for AppReceiver.apk looks
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.appreceiver.MyActivity" android:theme="#android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.appreceiver.MyReceiver">
<intent-filter>
<action android:name="com.appreceiver.CUSTOM_INTENT"></action>
</intent-filter>
</receiver>
</application>

Unable to save data using parse.com service

I have just started using Parse.com for back-end purpose for Android application. Although this seems to be trivial but I am struggling to get through. I followed basics step to test if data was sent. But I am not able to get it. My application on emulator ran successfully. At log level, I am seeing error with a log message : Authentication error: Unable to respond to any of these challenges: {}
I shall be grateful if any body can guide me through this scenario. I have also copied down the snippet of code.
ParseApplication.java
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, MY_APPLICATION_ID, MY_CLIENT_KEY");
/*// Add your initialization code here
Parse.initialize(this, YOUR_APPLICATION_ID, YOUR_CLIENT_KEY);*/
}
ParseStarterProjectActivity.java
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
ParseAnalytics.trackAppOpened(getIntent());
}
AndriodManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.parse.starter" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="ParseApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".ParseStarterProjectActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
May be you were making changes in APPLICATION ID and CLIENT KEY,that are not acceptible, try the same keys given at parse website page which come with your project name, hope you will get rid of this problem....
A bit late, but in your manifest, application name should have the full path:
android:name="com.parse.starter.ParseApplication"
ParseApplication is never instantiated, so your Parse.initialize is never called.

Categories

Resources