├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── app
├── .gitignore
├── build.gradle
├── google-services.json
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── net
│ │ └── simplifiedcoding
│ │ └── firebasecloudmessaging
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── net
│ │ │ └── simplifiedcoding
│ │ │ └── firebasecloudmessaging
│ │ │ ├── ActivitySendPushNotification.java
│ │ │ ├── EndPoints.java
│ │ │ ├── MainActivity.java
│ │ │ ├── MyFirebaseInstanceIDService.java
│ │ │ ├── MyFirebaseMessagingService.java
│ │ │ ├── MyNotificationManager.java
│ │ │ ├── MyVolley.java
│ │ │ └── SharedPrefManager.java
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── activity_send_push_notification.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── net
│ └── simplifiedcoding
│ └── firebasecloudmessaging
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.2"
6 | defaultConfig {
7 | applicationId "net.simplifiedcoding.firebasecloudmessaging"
8 | minSdkVersion 18
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:24.2.1'
28 | compile 'com.google.firebase:firebase-messaging:9.4.0'
29 | compile 'com.android.volley:volley:1.0.0'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
33 |
34 |
35 | apply plugin: 'com.google.gms.google-services'
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "691947741164",
4 | "firebase_url": "https://fcmsimplifiedcoding-41a16.firebaseio.com",
5 | "project_id": "fcmsimplifiedcoding-41a16",
6 | "storage_bucket": "fcmsimplifiedcoding-41a16.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:691947741164:android:6fd8868894e92239",
12 | "android_client_info": {
13 | "package_name": "net.simplifiedcoding.firebasecloudmessaging"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "691947741164-5ictrfs16pllitgat7duo3kg15jja03q.apps.googleusercontent.com",
19 | "client_type": 1,
20 | "android_info": {
21 | "package_name": "net.simplifiedcoding.firebasecloudmessaging",
22 | "certificate_hash": "034860729E02CCF968EC7093B280C25AB4104EE2"
23 | }
24 | },
25 | {
26 | "client_id": "691947741164-ekgp8i8rf5snea0ol4ofs3c2ddi30heq.apps.googleusercontent.com",
27 | "client_type": 3
28 | }
29 | ],
30 | "api_key": [
31 | {
32 | "current_key": "AIzaSyAUGmuZQ0fUydD2AhCr7cLxmrrbSEsyZLc"
33 | }
34 | ],
35 | "services": {
36 | "analytics_service": {
37 | "status": 1
38 | },
39 | "appinvite_service": {
40 | "status": 2,
41 | "other_platform_oauth_client": [
42 | {
43 | "client_id": "691947741164-ekgp8i8rf5snea0ol4ofs3c2ddi30heq.apps.googleusercontent.com",
44 | "client_type": 3
45 | }
46 | ]
47 | },
48 | "ads_service": {
49 | "status": 2
50 | }
51 | }
52 | }
53 | ],
54 | "configuration_version": "1"
55 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Belal/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/net/simplifiedcoding/firebasecloudmessaging/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.simplifiedcoding.firebasecloudmessaging", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/ActivitySendPushNotification.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | import android.app.ProgressDialog;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.text.TextUtils;
7 | import android.view.View;
8 | import android.widget.ArrayAdapter;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.RadioGroup;
12 | import android.widget.Spinner;
13 | import android.widget.Toast;
14 |
15 | import com.android.volley.AuthFailureError;
16 | import com.android.volley.Request;
17 | import com.android.volley.Response;
18 | import com.android.volley.VolleyError;
19 | import com.android.volley.toolbox.StringRequest;
20 |
21 | import org.json.JSONArray;
22 | import org.json.JSONException;
23 | import org.json.JSONObject;
24 |
25 | import java.util.ArrayList;
26 | import java.util.HashMap;
27 | import java.util.List;
28 | import java.util.Map;
29 |
30 | public class ActivitySendPushNotification extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {
31 |
32 | private Button buttonSendPush;
33 | private RadioGroup radioGroup;
34 | private Spinner spinner;
35 | private ProgressDialog progressDialog;
36 |
37 | private EditText editTextTitle, editTextMessage, editTextImage;
38 |
39 | private boolean isSendAllChecked;
40 | private List devices;
41 |
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_send_push_notification);
47 |
48 | radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
49 | spinner = (Spinner) findViewById(R.id.spinnerDevices);
50 | buttonSendPush = (Button) findViewById(R.id.buttonSendPush);
51 |
52 | editTextTitle = (EditText) findViewById(R.id.editTextTitle);
53 | editTextMessage = (EditText) findViewById(R.id.editTextMessage);
54 | editTextImage = (EditText) findViewById(R.id.editTextImageUrl);
55 |
56 | devices = new ArrayList<>();
57 |
58 | radioGroup.setOnCheckedChangeListener(this);
59 | buttonSendPush.setOnClickListener(this);
60 |
61 | loadRegisteredDevices();
62 | }
63 |
64 | //method to load all the devices from database
65 | private void loadRegisteredDevices() {
66 | progressDialog = new ProgressDialog(this);
67 | progressDialog.setMessage("Fetching Devices...");
68 | progressDialog.show();
69 |
70 | StringRequest stringRequest = new StringRequest(Request.Method.GET, EndPoints.URL_FETCH_DEVICES,
71 | new Response.Listener() {
72 | @Override
73 | public void onResponse(String response) {
74 | progressDialog.dismiss();
75 | JSONObject obj = null;
76 | try {
77 | obj = new JSONObject(response);
78 | if (!obj.getBoolean("error")) {
79 | JSONArray jsonDevices = obj.getJSONArray("devices");
80 |
81 | for (int i = 0; i < jsonDevices.length(); i++) {
82 | JSONObject d = jsonDevices.getJSONObject(i);
83 | devices.add(d.getString("email"));
84 | }
85 |
86 | ArrayAdapter arrayAdapter = new ArrayAdapter(
87 | ActivitySendPushNotification.this,
88 | android.R.layout.simple_spinner_dropdown_item,
89 | devices);
90 |
91 | spinner.setAdapter(arrayAdapter);
92 | }
93 | } catch (JSONException e) {
94 | e.printStackTrace();
95 | }
96 | }
97 | },
98 | new Response.ErrorListener() {
99 | @Override
100 | public void onErrorResponse(VolleyError error) {
101 |
102 | }
103 | }) {
104 |
105 | };
106 | MyVolley.getInstance(this).addToRequestQueue(stringRequest);
107 | }
108 |
109 | //this method will send the push
110 | //from here we will call sendMultiple() or sendSingle() push method
111 | //depending on the selection
112 | private void sendPush() {
113 | if (isSendAllChecked) {
114 | sendMultiplePush();
115 | } else {
116 | sendSinglePush();
117 | }
118 | }
119 |
120 | private void sendMultiplePush() {
121 | final String title = editTextTitle.getText().toString();
122 | final String message = editTextMessage.getText().toString();
123 | final String image = editTextImage.getText().toString();
124 |
125 | progressDialog.setMessage("Sending Push");
126 | progressDialog.show();
127 |
128 | StringRequest stringRequest = new StringRequest(Request.Method.POST, EndPoints.URL_SEND_MULTIPLE_PUSH,
129 | new Response.Listener() {
130 | @Override
131 | public void onResponse(String response) {
132 | progressDialog.dismiss();
133 |
134 | Toast.makeText(ActivitySendPushNotification.this, response, Toast.LENGTH_LONG).show();
135 | }
136 | },
137 | new Response.ErrorListener() {
138 | @Override
139 | public void onErrorResponse(VolleyError error) {
140 |
141 | }
142 | }) {
143 | @Override
144 | protected Map getParams() throws AuthFailureError {
145 | Map params = new HashMap<>();
146 | params.put("title", title);
147 | params.put("message", message);
148 |
149 | if (!TextUtils.isEmpty(image))
150 | params.put("image", image);
151 | return params;
152 | }
153 | };
154 |
155 | MyVolley.getInstance(this).addToRequestQueue(stringRequest);
156 | }
157 |
158 | private void sendSinglePush() {
159 | final String title = editTextTitle.getText().toString();
160 | final String message = editTextMessage.getText().toString();
161 | final String image = editTextImage.getText().toString();
162 | final String email = spinner.getSelectedItem().toString();
163 |
164 | progressDialog.setMessage("Sending Push");
165 | progressDialog.show();
166 |
167 | StringRequest stringRequest = new StringRequest(Request.Method.POST, EndPoints.URL_SEND_SINGLE_PUSH,
168 | new Response.Listener() {
169 | @Override
170 | public void onResponse(String response) {
171 | progressDialog.dismiss();
172 |
173 | Toast.makeText(ActivitySendPushNotification.this, response, Toast.LENGTH_LONG).show();
174 | }
175 | },
176 | new Response.ErrorListener() {
177 | @Override
178 | public void onErrorResponse(VolleyError error) {
179 |
180 | }
181 | }) {
182 | @Override
183 | protected Map getParams() throws AuthFailureError {
184 | Map params = new HashMap<>();
185 | params.put("title", title);
186 | params.put("message", message);
187 |
188 | if (!TextUtils.isEmpty(image))
189 | params.put("image", image);
190 |
191 | params.put("email", email);
192 | return params;
193 | }
194 | };
195 |
196 | MyVolley.getInstance(this).addToRequestQueue(stringRequest);
197 | }
198 |
199 | @Override
200 | public void onCheckedChanged(RadioGroup radioGroup, int i) {
201 | switch (radioGroup.getCheckedRadioButtonId()) {
202 | case R.id.radioButtonSendAll:
203 | isSendAllChecked = true;
204 | spinner.setEnabled(false);
205 | break;
206 |
207 | case R.id.radioButtonSendOne:
208 | isSendAllChecked = false;
209 | spinner.setEnabled(true);
210 | break;
211 |
212 | }
213 | }
214 |
215 | @Override
216 | public void onClick(View view) {
217 | //calling the method send push on button click
218 | sendPush();
219 | }
220 | }
221 |
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/EndPoints.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | /**
4 | * Created by Belal on 04/11/16.
5 | */
6 |
7 | public class EndPoints {
8 | public static final String URL_REGISTER_DEVICE = "http://192.168.1.101/FcmExample/RegisterDevice.php";
9 | public static final String URL_SEND_SINGLE_PUSH = "http://192.168.1.101/FcmExample/sendSinglePush.php";
10 | public static final String URL_SEND_MULTIPLE_PUSH = "http://192.168.1.101/FcmExample/sendMultiplePush.php";
11 | public static final String URL_FETCH_DEVICES = "http://192.168.1.101/FcmExample/GetRegisteredDevices.php";
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/MainActivity.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Intent;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.ProgressBar;
11 | import android.widget.TextView;
12 | import android.widget.Toast;
13 |
14 | import com.android.volley.AuthFailureError;
15 | import com.android.volley.Request;
16 | import com.android.volley.RequestQueue;
17 | import com.android.volley.Response;
18 | import com.android.volley.VolleyError;
19 | import com.android.volley.toolbox.StringRequest;
20 | import com.android.volley.toolbox.Volley;
21 |
22 | import org.json.JSONException;
23 | import org.json.JSONObject;
24 |
25 | import java.util.HashMap;
26 | import java.util.Map;
27 |
28 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
29 |
30 | //defining views
31 | private Button buttonSendPush;
32 | private Button buttonRegister;
33 | private EditText editTextEmail;
34 | private ProgressDialog progressDialog;
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_main);
40 |
41 | //getting views from xml
42 | editTextEmail = (EditText) findViewById(R.id.editTextEmail);
43 | buttonRegister = (Button) findViewById(R.id.buttonRegister);
44 | buttonSendPush = (Button) findViewById(R.id.buttonSendNotification);
45 |
46 | //adding listener to view
47 | buttonRegister.setOnClickListener(this);
48 | buttonSendPush.setOnClickListener(this);
49 | }
50 |
51 | //storing token to mysql server
52 | private void sendTokenToServer() {
53 | progressDialog = new ProgressDialog(this);
54 | progressDialog.setMessage("Registering Device...");
55 | progressDialog.show();
56 |
57 | final String token = SharedPrefManager.getInstance(this).getDeviceToken();
58 | final String email = editTextEmail.getText().toString();
59 |
60 | if (token == null) {
61 | progressDialog.dismiss();
62 | Toast.makeText(this, "Token not generated", Toast.LENGTH_LONG).show();
63 | return;
64 | }
65 |
66 | StringRequest stringRequest = new StringRequest(Request.Method.POST, EndPoints.URL_REGISTER_DEVICE,
67 | new Response.Listener() {
68 | @Override
69 | public void onResponse(String response) {
70 | progressDialog.dismiss();
71 | try {
72 | JSONObject obj = new JSONObject(response);
73 | Toast.makeText(MainActivity.this, obj.getString("message"), Toast.LENGTH_LONG).show();
74 | } catch (JSONException e) {
75 | e.printStackTrace();
76 | }
77 | }
78 | },
79 | new Response.ErrorListener() {
80 | @Override
81 | public void onErrorResponse(VolleyError error) {
82 | progressDialog.dismiss();
83 | Toast.makeText(MainActivity.this, error.getMessage(), Toast.LENGTH_LONG).show();
84 | }
85 | }) {
86 |
87 | @Override
88 | protected Map getParams() throws AuthFailureError {
89 | Map params = new HashMap<>();
90 | params.put("email", email);
91 | params.put("token", token);
92 | return params;
93 | }
94 | };
95 | MyVolley.getInstance(this).addToRequestQueue(stringRequest);
96 | }
97 |
98 | @Override
99 | public void onClick(View view) {
100 | if (view == buttonRegister) {
101 | sendTokenToServer();
102 | }
103 |
104 | //starting send notification activity
105 | if (view == buttonSendPush) {
106 | startActivity(new Intent(this, ActivitySendPushNotification.class));
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/MyFirebaseInstanceIDService.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | import android.util.Log;
4 |
5 | import com.google.firebase.iid.FirebaseInstanceId;
6 | import com.google.firebase.iid.FirebaseInstanceIdService;
7 |
8 | /**
9 | * Created by Belal on 03/11/16.
10 | */
11 |
12 |
13 | public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
14 |
15 | private static final String TAG = "MyFirebaseIIDService";
16 |
17 | @Override
18 | public void onTokenRefresh() {
19 | String refreshedToken = FirebaseInstanceId.getInstance().getToken();
20 | Log.d(TAG, "Refreshed token: " + refreshedToken);
21 | storeToken(refreshedToken);
22 | }
23 |
24 | private void storeToken(String token) {
25 | //saving the token on shared preferences
26 | SharedPrefManager.getInstance(getApplicationContext()).saveDeviceToken(token);
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/MyFirebaseMessagingService.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 |
4 | import android.content.Intent;
5 | import android.util.Log;
6 |
7 | import com.google.firebase.messaging.FirebaseMessagingService;
8 | import com.google.firebase.messaging.RemoteMessage;
9 |
10 | import org.json.JSONException;
11 | import org.json.JSONObject;
12 |
13 | /**
14 | * Created by Belal on 03/11/16.
15 | */
16 |
17 | public class MyFirebaseMessagingService extends FirebaseMessagingService {
18 |
19 | private static final String TAG = "MyFirebaseMsgService";
20 |
21 | @Override
22 | public void onMessageReceived(RemoteMessage remoteMessage) {
23 | if (remoteMessage.getData().size() > 0) {
24 | Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
25 | try {
26 | JSONObject json = new JSONObject(remoteMessage.getData().toString());
27 | sendPushNotification(json);
28 | } catch (Exception e) {
29 | Log.e(TAG, "Exception: " + e.getMessage());
30 | }
31 | }
32 | }
33 |
34 | //this method will display the notification
35 | //We are passing the JSONObject that is received from
36 | //firebase cloud messaging
37 | private void sendPushNotification(JSONObject json) {
38 | //optionally we can display the json into log
39 | Log.e(TAG, "Notification JSON " + json.toString());
40 | try {
41 | //getting the json data
42 | JSONObject data = json.getJSONObject("data");
43 |
44 | //parsing json data
45 | String title = data.getString("title");
46 | String message = data.getString("message");
47 | String imageUrl = data.getString("image");
48 |
49 | //creating MyNotificationManager object
50 | MyNotificationManager mNotificationManager = new MyNotificationManager(getApplicationContext());
51 |
52 | //creating an intent for the notification
53 | Intent intent = new Intent(getApplicationContext(), MainActivity.class);
54 |
55 | //if there is no image
56 | if(imageUrl.equals("null")){
57 | //displaying small notification
58 | mNotificationManager.showSmallNotification(title, message, intent);
59 | }else{
60 | //if there is an image
61 | //displaying a big notification
62 | mNotificationManager.showBigNotification(title, message, imageUrl, intent);
63 | }
64 | } catch (JSONException e) {
65 | Log.e(TAG, "Json Exception: " + e.getMessage());
66 | } catch (Exception e) {
67 | Log.e(TAG, "Exception: " + e.getMessage());
68 | }
69 | }
70 |
71 | }
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/MyNotificationManager.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | /**
4 | * Created by Belal on 03/11/16.
5 | */
6 |
7 | import android.app.Notification;
8 | import android.app.NotificationManager;
9 | import android.app.PendingIntent;
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.graphics.Bitmap;
13 | import android.graphics.BitmapFactory;
14 | import android.support.v4.app.NotificationCompat;
15 | import android.text.Html;
16 |
17 | import java.io.IOException;
18 | import java.io.InputStream;
19 | import java.net.HttpURLConnection;
20 | import java.net.URL;
21 |
22 |
23 | /**
24 | * Created by Ravi on 31/03/15.
25 | */
26 |
27 | public class MyNotificationManager {
28 |
29 | public static final int ID_BIG_NOTIFICATION = 234;
30 | public static final int ID_SMALL_NOTIFICATION = 235;
31 |
32 | private Context mCtx;
33 |
34 | public MyNotificationManager(Context mCtx) {
35 | this.mCtx = mCtx;
36 | }
37 |
38 | //the method will show a big notification with an image
39 | //parameters are title for message title, message for message text, url of the big image and an intent that will open
40 | //when you will tap on the notification
41 | public void showBigNotification(String title, String message, String url, Intent intent) {
42 | PendingIntent resultPendingIntent =
43 | PendingIntent.getActivity(
44 | mCtx,
45 | ID_BIG_NOTIFICATION,
46 | intent,
47 | PendingIntent.FLAG_UPDATE_CURRENT
48 | );
49 | NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
50 | bigPictureStyle.setBigContentTitle(title);
51 | bigPictureStyle.setSummaryText(Html.fromHtml(message).toString());
52 | bigPictureStyle.bigPicture(getBitmapFromURL(url));
53 | NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mCtx);
54 | Notification notification;
55 | notification = mBuilder.setSmallIcon(R.mipmap.ic_launcher).setTicker(title).setWhen(0)
56 | .setAutoCancel(true)
57 | .setContentIntent(resultPendingIntent)
58 | .setContentTitle(title)
59 | .setStyle(bigPictureStyle)
60 | .setSmallIcon(R.mipmap.ic_launcher)
61 | .setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher))
62 | .setContentText(message)
63 | .build();
64 |
65 | notification.flags |= Notification.FLAG_AUTO_CANCEL;
66 |
67 | NotificationManager notificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
68 | notificationManager.notify(ID_BIG_NOTIFICATION, notification);
69 | }
70 |
71 | //the method will show a small notification
72 | //parameters are title for message title, message for message text and an intent that will open
73 | //when you will tap on the notification
74 | public void showSmallNotification(String title, String message, Intent intent) {
75 | PendingIntent resultPendingIntent =
76 | PendingIntent.getActivity(
77 | mCtx,
78 | ID_SMALL_NOTIFICATION,
79 | intent,
80 | PendingIntent.FLAG_UPDATE_CURRENT
81 | );
82 |
83 |
84 | NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mCtx);
85 | Notification notification;
86 | notification = mBuilder.setSmallIcon(R.mipmap.ic_launcher).setTicker(title).setWhen(0)
87 | .setAutoCancel(true)
88 | .setContentIntent(resultPendingIntent)
89 | .setContentTitle(title)
90 | .setSmallIcon(R.mipmap.ic_launcher)
91 | .setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher))
92 | .setContentText(message)
93 | .build();
94 |
95 | notification.flags |= Notification.FLAG_AUTO_CANCEL;
96 |
97 | NotificationManager notificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
98 | notificationManager.notify(ID_SMALL_NOTIFICATION, notification);
99 | }
100 |
101 | //The method will return Bitmap from an image URL
102 | private Bitmap getBitmapFromURL(String strURL) {
103 | try {
104 | URL url = new URL(strURL);
105 | HttpURLConnection connection = (HttpURLConnection) url.openConnection();
106 | connection.setDoInput(true);
107 | connection.connect();
108 | InputStream input = connection.getInputStream();
109 | Bitmap myBitmap = BitmapFactory.decodeStream(input);
110 | return myBitmap;
111 | } catch (IOException e) {
112 | e.printStackTrace();
113 | return null;
114 | }
115 | }
116 | }
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/MyVolley.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.support.v4.util.LruCache;
6 |
7 | import com.android.volley.Request;
8 | import com.android.volley.RequestQueue;
9 | import com.android.volley.toolbox.ImageLoader;
10 | import com.android.volley.toolbox.Volley;
11 |
12 | /**
13 | * Created by Belal on 13/10/16.
14 | */
15 |
16 | public class MyVolley {
17 |
18 | private static MyVolley mInstance;
19 | private RequestQueue mRequestQueue;
20 | private static Context mCtx;
21 |
22 | private MyVolley(Context context) {
23 | mCtx = context;
24 | mRequestQueue = getRequestQueue();
25 | }
26 |
27 | public static synchronized MyVolley getInstance(Context context) {
28 | if (mInstance == null) {
29 | mInstance = new MyVolley(context);
30 | }
31 | return mInstance;
32 | }
33 |
34 | public RequestQueue getRequestQueue() {
35 | if (mRequestQueue == null) {
36 | // getApplicationContext() is key, it keeps you from leaking the
37 | // Activity or BroadcastReceiver if someone passes one in.
38 | mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
39 | }
40 | return mRequestQueue;
41 | }
42 |
43 | public void addToRequestQueue(Request req) {
44 | getRequestQueue().add(req);
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/net/simplifiedcoding/firebasecloudmessaging/SharedPrefManager.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | /**
7 | * Created by Belal on 03/11/16.
8 | */
9 |
10 | public class SharedPrefManager {
11 | private static final String SHARED_PREF_NAME = "FCMSharedPref";
12 | private static final String TAG_TOKEN = "tagtoken";
13 |
14 | private static SharedPrefManager mInstance;
15 | private static Context mCtx;
16 |
17 | private SharedPrefManager(Context context) {
18 | mCtx = context;
19 | }
20 |
21 | public static synchronized SharedPrefManager getInstance(Context context) {
22 | if (mInstance == null) {
23 | mInstance = new SharedPrefManager(context);
24 | }
25 | return mInstance;
26 | }
27 |
28 | //this method will save the device token to shared preferences
29 | public boolean saveDeviceToken(String token){
30 | SharedPreferences sharedPreferences = mCtx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
31 | SharedPreferences.Editor editor = sharedPreferences.edit();
32 | editor.putString(TAG_TOKEN, token);
33 | editor.apply();
34 | return true;
35 | }
36 |
37 | //this method will fetch the device token from shared preferences
38 | public String getDeviceToken(){
39 | SharedPreferences sharedPreferences = mCtx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
40 | return sharedPreferences.getString(TAG_TOKEN, null);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
19 |
20 |
26 |
27 |
28 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_send_push_notification.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
34 |
38 |
39 |
44 |
45 |
50 |
51 |
56 |
57 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/probelalkhan/android-push-using-firebase-cloud-messaging/80f94bfe2e0693899ab41b5009c46b7f1f397815/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/probelalkhan/android-push-using-firebase-cloud-messaging/80f94bfe2e0693899ab41b5009c46b7f1f397815/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/probelalkhan/android-push-using-firebase-cloud-messaging/80f94bfe2e0693899ab41b5009c46b7f1f397815/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/probelalkhan/android-push-using-firebase-cloud-messaging/80f94bfe2e0693899ab41b5009c46b7f1f397815/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/probelalkhan/android-push-using-firebase-cloud-messaging/80f94bfe2e0693899ab41b5009c46b7f1f397815/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FirebaseCloudMessaging
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/net/simplifiedcoding/firebasecloudmessaging/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.simplifiedcoding.firebasecloudmessaging;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | classpath 'com.google.gms:google-services:3.0.0'
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/probelalkhan/android-push-using-firebase-cloud-messaging/80f94bfe2e0693899ab41b5009c46b7f1f397815/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------