Yes, It is possible.
Message API (you can use any format JSON or XML) Android Service which will connect to that Message API and check for new message - And you might also need
BroadcastReceiver
Here is some code that I used.
Firstly I create BroadcastReceiver and Service in AndroidManifest.xml
<receiver android:name="com.example.Push_Notification" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="android.net.wifi.WIFI_STATE_CHANGED" /> <action android:name="android.net.wifi.NETWORK_IDS_CHANGED" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <service android:name="com.example.Push_Notification_Checker" android:enabled="true" />
This is Push_Notification :
public class Push_Notification extends BroadcastReceiver{ private Context context; @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub this.context = context; startService(); } public void startService(){ ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE ); NetworkInfo activeNetInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE|ConnectivityManager.TYPE_WIFI); boolean isConnected = activeNetInfo != null && activeNetInfo.isConnectedOrConnecting(); Calendar cur_cal = Calendar.getInstance(); cur_cal.setTimeInMillis(System.currentTimeMillis()); Intent i = new Intent(context, Push_Notification_Checker.class); PendingIntent pintent = PendingIntent.getService(context, 0, i, 0); AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); if (isConnected){ catchLog("connecte " +isConnected); alarm.setRepeating(AlarmManager.RTC_WAKEUP, cur_cal.getTimeInMillis(), 1 * 60*1000, pintent); } else { catchLog("not connecte " +isConnected); alarm.cancel(pintent); } } private void catchLog(String log) { Log.i("PushNotification", log); } }
This is Push_Notification_Checker service. :
public class Push_Notification_Checker extends Service { @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); catchLog("Service got created"); nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); pref = getSharedPreferences(Constants.SHARED_PRED, 0); } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); //Here i call AsyncTask to check Message. Android didn't allow Network Connection directly tied into Main Thread new GetMessage(getApplicationContext()).execute(); } }
By sending android UDID to server, you can check whether there is new message for the particular device. This way you can send message to specific device. How to getUDID ?
Here is why I use AsyncTask to connect and these two examples can help you with how to communicate with server.
how to send data to server using android by Http post method?
Send data from android to server via JSON
I know this is a long shot but hope this can help you in some way.
P.S: I'm also from the one of the country denied by Google