tag:blogger.com,1999:blog-65534554413701313952024-03-05T15:45:03.681-08:00Firzan's BlogAnonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6553455441370131395.post-51376413458058527132016-08-21T04:20:00.000-07:002016-08-21T08:17:27.326-07:00Android Firebase Cloud Messaging<div dir="ltr" style="text-align: left;" trbidi="on">
this titorial is written with the consideration that you are familiar with GCM. if you are new to firebase please follow the official documentaion.<br />
<br />
<br />
1 . go to the <a href="https://console.firebase.google.com/" target="_blank">Firebase Console</a> and create new project or you can import existing gcm project into firebase.<br />
<br />
2. after project creating go to the <b><span style="color: blue;">project setting</span></b> from top left cornet (click setting icon).<br />
3. enter your package name , and download the google-services.json<br />
4. copy google-services.json into your app directory .<br />
5. add rules to your root-level <code>build.gradle</code> file, to
include the google-services plugin:<br />
<br />
<pre class="prettyprint notranslate" translate="no"><code><span class="pln">buildscript </span><span class="pun">{</span><span class="pln">
</span><span class="com">// ...</span><span class="pln">
dependencies </span><span class="pun">{</span><span class="pln">
</span><span class="com">// ...</span><span class="pln">
classpath </span><span class="str">'com.google.gms:google-services:3.0.0'</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span></code></pre>
<pre class="prettyprint notranslate" translate="no"><code><span class="pun">
</span></code></pre>
<pre class="prettyprint notranslate" translate="no">6. Then, in your module Gradle file (usually the <code>app/build.gradle</code>), add the
<code>apply plugin</code> line at the bottom of the file to enable the Gradle plugin:</pre>
<pre class="prettyprint notranslate" translate="no"></pre>
<pre class="prettyprint notranslate" translate="no"><pre class="devsite-code-button-clone"><div aria-label="Click to copy" class="gc-analytics-event material-icons devsite-click-to-copy-button" data-category="Site-Wide Custom Events" data-label="Click To Copy" data-title="Click to copy" data-tooltip-align="b,c" data-tooltip="Click to copy" track-name="clickToCopy" track-type="exampleCode">
</div>
<code><span class="pln">apply plugin</span><span class="pun">:</span><span class="pln"> </span><span class="str">'com.android.application'</span><span class="pln">
android </span><span class="pun">{</span><span class="pln">
</span><span class="com">// ...</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
dependencies </span><span class="pun">{</span><span class="pln">
</span><span class="com">// ...</span><span class="pln">
</span><span class="pln"> com.google.firebase:firebase-messaging:9.4.0</span><span class="pun">}</span><span class="pln">
</span><span class="com">// ADD THIS AT THE BOTTOM</span><span class="pln">
apply plugin</span><span class="pun">:</span><span class="pln"> </span><span class="str">'com.google.gms.google-services'</span></code></pre>
<pre class="devsite-code-button-clone"><b><span style="color: red;">Note :</span></b> please check libraries are available for the different Firebase features.</pre>
<pre class="devsite-code-button-clone"><a href="https://firebase.google.com/docs/android/setup">https://firebase.google.com/docs/android/setup</a></pre>
<pre class="devsite-code-button-clone"></pre>
<pre class="devsite-code-button-clone">7. <b>Retrieve the current registration token</b></pre>
<pre class="devsite-code-button-clone"> When you need to retrieve the current token, call <a href="https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId.html#public-methods"><code>FirebaseInstanceID.getToken()</code></a>.
This method returns null if the token has not yet been generated.</pre>
<pre class="devsite-code-button-clone"><pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><span style="color: navy; font-weight: bold;">
</span></pre>
<pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><span style="color: navy; font-weight: bold;">public class </span>FirebaseInstanceIDService <span style="color: navy; font-weight: bold;">extends </span></pre>
<pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;">FirebaseInstanceIdService {
<span style="color: navy; font-weight: bold;">private static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">TAG </span>= <span style="color: green; font-weight: bold;">"MyFirebaseIIDService"</span>;<span style="color: olive; font-size: 12pt;"> </span></pre>
<pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: olive;"> @Override</span><span style="color: navy; font-weight: bold;"> </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: navy; font-weight: bold;"> public void </span>onTokenRefresh() {
<span style="color: grey; font-style: italic;">// Get updated InstanceID token.</span><span style="color: grey; font-style: italic;"> </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: grey; font-style: italic;"> </span>String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.<span style="font-style: italic;">d</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">TAG</span>, <span style="color: green; font-weight: bold;">"Refreshed token: " </span>+ refreshedToken);
<span style="color: grey; font-style: italic;">// If you want to send messages to </span><span style="font-size: 12pt; font-style: italic;">this application instance or</span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="font-size: 12pt; font-style: italic;"> // manage this apps subscriptions on the server side, send the</span><span style="font-size: 12pt; font-style: italic;"> </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="font-size: 12pt; font-style: italic;">// Instance ID token to your app server.</span><span style="font-size: 12pt;"><i> </i></span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="font-size: 12pt;"><i>// send this token to your server so you can start </i></span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: grey;"><i>// downstream messages to client.</i></span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"> }</pre>
</pre>
<pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;">}</pre>
</pre>
<pre class="devsite-code-button-clone"><b>8. Handle Message receiving </b></pre>
<pre class="devsite-code-button-clone"></pre>
<pre class="devsite-code-button-clone">create new service which extends <span style="background-color: #e4e4ff; font-family: "courier new"; font-size: 12pt;">FirebaseMessagingService</span> . </pre>
<pre class="devsite-code-button-clone">here i've created My<span style="background-color: #e4e4ff; font-family: "courier new"; font-size: 12pt;">FirebaseMessagingService.java</span></pre>
<pre class="devsite-code-button-clone"><span style="background-color: #e4e4ff; font-family: "courier new"; font-size: 12pt;">
</span></pre>
<pre class="devsite-code-button-clone"><span style="background-color: #e4e4ff; font-family: "courier new"; font-size: 12pt;">example </span></pre>
<pre class="devsite-code-button-clone"></pre>
<pre class="devsite-code-button-clone"><pre style="font-family: "Courier New"; font-size: 12pt;"><span style="background-color: #d9d2e9;"><span style="color: navy; font-weight: bold;">public class <span style="font-size: small;">My</span><span style="background-color: #e4e4ff; font-family: "courier new"; font-size: 12pt;">FirebaseMessagingService</span></span></span><span style="background-color: #d9d2e9; color: navy; font-size: 12pt; font-weight: bold;">extends </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="background-color: #d9d2e9;"> FirebaseMessagingService {</span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="background-color: #d9d2e9;">
</span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * Called when message is received.</span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: grey; font-style: italic;">*</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">remoteMessage </span><span style="color: grey; font-style: italic;">Object representing the </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: grey; font-style: italic;">message received from Firebase Cloud Messaging.</span><span style="color: grey; font-style: italic;"> </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;">// [START receive_message]</span></pre>
</pre>
<pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><span style="color: olive;">@Override</span><span style="color: navy; font-weight: bold;">public void </span>onMessageReceived(RemoteMessage remoteMessage) </pre>
<pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;">{</pre>
</pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"> Log.<span style="font-style: italic;">d</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">TAG</span>, <span style="color: green; font-weight: bold;">"From: " </span>+ remoteMessage.getFrom());</pre>
<pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: grey; font-style: italic;"> // Check if message contains a data payload.</span><span style="color: navy; font-weight: bold;"> </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: navy; font-weight: bold;"> if </span>(remoteMessage.getData().size() > <span style="color: blue;">0</span>) {
Log.<span style="font-style: italic;">d</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">TAG</span>, <span style="color: green; font-weight: bold;">"Message data payload: " </span>+ remoteMessage.getData());
}
<span style="color: grey; font-style: italic;"> // Check if message contains a notification payload.</span><span style="color: navy; font-weight: bold;"> </span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="color: navy; font-weight: bold;"> if </span>(remoteMessage.getNotification() != <span style="color: navy; font-weight: bold;">null</span>) {
Log.<span style="font-style: italic;">d</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">TAG</span>, <span style="color: green; font-weight: bold;">"Message Notification Body: " </span>+ remoteMessage.getNotification().getBody());</pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"> }</pre>
</pre>
</pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="background-color: #d9d2e9;">}</span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="background-color: #d9d2e9;">
</span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><span style="background-color: #d9d2e9;">
</span></pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><pre class="devsite-code-button-clone" style="font-size: medium;"><b>9. AndroidManifest.xml</b></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><b>
</b></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><<span style="color: navy; font-weight: bold;">service</span><span style="color: navy; font-weight: bold;"> </span><span style="color: #660e7a; font-weight: bold;">android</span><span style="color: blue; font-weight: bold;">:name=</span><span style="color: green; font-weight: bold;">".MyFirebaseMessagingService"</span>>
<<span style="color: navy; font-weight: bold;">intent-filter</span>>
<<span style="color: navy; font-weight: bold;">action </span><span style="color: #660e7a; font-weight: bold;">android</span><span style="color: blue; font-weight: bold;">:name=</span><span style="color: green; font-weight: bold;">"com.google.firebase.MESSAGING_EVENT"</span>/>
</<span style="color: navy; font-weight: bold;">intent-filter</span>>
</<span style="color: navy; font-weight: bold;">service</span>><span style="color: grey; font-style: italic;">
</span><<span style="color: navy; font-weight: bold;">service</span><span style="color: navy; font-weight: bold;"> </span><span style="color: #660e7a; font-weight: bold;">android</span><span style="color: blue; font-weight: bold;">:name=</span><span style="color: green; font-weight: bold;">".FirebaseInstanceIDService"</span>>
<<span style="color: navy; font-weight: bold;">intent-filter</span>>
<<span style="color: navy; font-weight: bold;">action </span><span style="color: #660e7a; font-weight: bold;">android</span><span style="color: blue; font-weight: bold;">:name=</span><span style="color: green; font-weight: bold;">"com.google.firebase.INSTANCE_ID_EVENT"</span>/>
</<span style="color: navy; font-weight: bold;">intent-filter</span>>
</<span style="color: navy; font-weight: bold;">service</span>>
</pre>
</pre>
</pre>
<pre style="font-family: "Courier New"; font-size: 12pt;"><pre class="devsite-code-button-clone" style="font-size: medium;"><b>10. Your MainActivity</b></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;">//get token</pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><span class="pl-smi" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">String</span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;"> token </span><span class="pl-k" style="background-color: white; box-sizing: border-box; color: #a71d5d; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">=</span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;"> </span><span class="pl-smi" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">FirebaseInstanceId</span><span class="pl-k" style="background-color: white; box-sizing: border-box; color: #a71d5d; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">.</span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">getInstance()</span><span class="pl-k" style="background-color: white; box-sizing: border-box; color: #a71d5d; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">.</span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">getToken();</span></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">
</span></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">//start subsription to firebase</span></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><span class="pl-smi" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">FirebaseMessaging</span><span class="pl-k" style="background-color: white; box-sizing: border-box; color: #a71d5d; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">.</span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">getInstance()</span><span class="pl-k" style="background-color: white; box-sizing: border-box; color: #a71d5d; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">.</span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">subscribeToTopic(</span><span class="pl-s" style="background-color: white; box-sizing: border-box; color: #183691; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;"><span class="pl-pds" style="box-sizing: border-box;">"</span>news<span class="pl-pds" style="box-sizing: border-box;">"</span></span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">);</span></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">
</span></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; line-height: 20px;">//for unsubscribtion</span></pre>
<pre class="devsite-code-button-clone" style="font-size: medium;"><pre style="background-color: white; font-family: "Courier New"; font-size: 12pt;"><span style="background-color: #e4e4ff;">FirebaseMessaging</span>.<span style="font-style: italic;">getInstance</span>().unsubscribeFromTopic(<span style="color: green; font-weight: bold;">"news"</span>);</pre>
</pre>
</pre>
11. SERVER CODE FOR SENDING MESSAGES</pre>
<pre class="devsite-code-button-clone">
</pre>
<pre class="devsite-code-button-clone">please refer following link</pre>
<pre class="devsite-code-button-clone">
</pre>
<pre class="devsite-code-button-clone">https://github.com/firzan/php/edit/master/Gcm.php</pre>
</pre>
</div>
Anonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.com0tag:blogger.com,1999:blog-6553455441370131395.post-50971217354398294392014-10-02T21:59:00.002-07:002014-10-02T21:59:44.559-07:00Android upload file to PHP server with parameters using progress bar<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
new ProcessFileUploadTask(new File(Environment.getExternalStorageDirectory().toString()+"/yourfile_name/";<br />
<br />
<br />
//asynch task to upload file with parameters<br />
public class ProcessFileUploadTask extends AsyncTask<Void, Integer, Void> implements DialogInterface.OnCancelListener{<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> private ProgressDialog progressDialog;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> private File file;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String res="";<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> public ProcessFileUploadTask(File file) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> this.file = file;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> @Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// can use UI thread here<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected void onPreExecute() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>super.onPreExecute();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>try{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>progressDialog = new ProgressDialog(PostDataActivity.this);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>progressDialog.setMessage("Uploading... Please wait!");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>progressDialog.setIndeterminate(false);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>progressDialog.setMax(file_size);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>progressDialog.setCancelable(false);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> progressDialog.setCanceledOnTouchOutside(false);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> progressDialog.show();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>catch(Exception e){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Log.e("Exception:",e.toString());<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected void onPostExecute(Void v) { <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>progressDialog.dismiss();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> Toast toast=Toast.makeText(getApplicationContext(), "Uploaded Successfully.", Toast.LENGTH_LONG);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> @Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> protected Void doInBackground(Void... v) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> HttpURLConnection.setFollowRedirects(false);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> HttpURLConnection conn = null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> try {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>//posting parameters with url<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String finalUrl = Uri.parse("www.example.com/demo.php")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> .buildUpon()<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> .appendQueryParameter("name", "firzan")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> .build().toString();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn = (HttpURLConnection) new URL(finalUrl).openConnection();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn.setConnectTimeout(10*1000);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn.setRequestMethod("POST");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String boundary = "---------------------------boundary";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String tail = "\r\n--" + boundary + "--\r\n";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn.setDoOutput(true);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String metadataPart = "--" + boundary + "\r\n"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> + "Content-Disposition: form-data; name=\"metadata\"\r\n\r\n"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> + "" + "\r\n";<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String fileHeader1 = "--" + boundary + "\r\n"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> + "Content-Disposition: form-data; name=\"uploadedfile\"; filename=\""<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> + serverFileName + "\"\r\n"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> + "Content-Type: application/octet-stream\r\n"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> + "Content-Transfer-Encoding: binary\r\n";<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> long fileLength = file.length() + tail.length();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String fileHeader2 = "Content-length: " + fileLength + "\r\n";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String fileHeader = fileHeader1 + fileHeader2 + "\r\n";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String stringData = metadataPart + fileHeader;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> long requestLength = stringData.length() + fileLength;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn.setRequestProperty("Content-length", "" + requestLength);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn.setFixedLengthStreamingMode((int) requestLength);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> conn.connect();<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> DataOutputStream out = new DataOutputStream(conn.getOutputStream());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> out.writeBytes(stringData);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> out.flush();<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> int progress = 0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> int bytesRead = 0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> byte buf[] = new byte[10*1024];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> BufferedInputStream bufInput = new BufferedInputStream(new FileInputStream(file));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> while ((bytesRead = bufInput.read(buf)) != -1) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> // write output<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> out.write(buf, 0, bytesRead);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> out.flush();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> progress += bytesRead;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> // update progress bar<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> publishProgress(progress);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> // Write closing boundary and close stream<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> out.writeBytes(tail);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> out.flush();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> out.close();<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> // Get server response<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> String line = "";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> StringBuilder builder = new StringBuilder();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> while((line = reader.readLine()) != null) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> builder.append(line);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>serverResponseCode = conn.getResponseCode();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>serverResponseMessage = conn.getResponseMessage();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>ServerResponce=builder.toString();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>Log.e("ser res",ServerResponce.toString());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> catch (Exception e) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> Log.e("Exception",e.toString());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> progressDialog.dismiss();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> exceptionText=e.toString();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> } finally { <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> if (conn != null) conn.disconnect();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> //finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> return null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> @Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> protected void onProgressUpdate(Integer... progress) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> progressDialog.setProgress((int) (progress[0]));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> @Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> public void onCancel(DialogInterface dialog) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> super.onCancelled();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> cancel(true);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> dialog.dismiss();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<br />
<br />
<br />
<span style="color: red;">PHP Script</span><br />
<br />
<?php<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
$name=$_REQUEST['name'];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$target_path_videos = 'videos/'; <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$target_path_videos = $target_path_videos .'_'. basename( $_FILES['uploadedfile']['name']);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path_videos))<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>echo '1';<br />
}<br />
else<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo "Error";<br />
}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
?></div>
Anonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.com0tag:blogger.com,1999:blog-6553455441370131395.post-35319395909938682352014-10-02T21:35:00.000-07:002014-10-02T21:35:24.338-07:00Android Sliding Menu using Navigation Drawer/ Hamburger<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: #fefdfa; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18.2000007629395px;">Download the Demo Project From Following link and import it in your eclipse ide.</span><br />
<span style="background-color: #fefdfa; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18.2000007629395px;"><br /></span>
<b><a href="https://drive.google.com/file/d/0B7370Q3RTbaSTzZxcWVyaHNvNjA/view?usp=sharing" target="_blank"><span style="color: red;">Download</span></a></b><br />
<span style="color: red;"><br /></span>
<div style="text-align: justify;">
1. Find the String variables for List View items and icon names in strings.xml<span style="font-family: Open Sans, sans-serif;"><span style="background-color: white; font-size: 15px; line-height: 25px;">.(change as per your needs.)</span></span></div>
<div style="text-align: justify;">
<span style="font-family: Open Sans, sans-serif;"><span style="background-color: white; font-size: 15px; line-height: 25px;">2. </span></span><span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;">Android introduced a newer UI element called</span><span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;"> </span><span style="color: red;"><a class="link" href="http://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html" style="border: none; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;" target="_blank">DrawerLayout</a><span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;"> </span></span><span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;">for Navigation Drawer. Open your layout file (</span><strong style="font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;">activity_main.xml</strong><span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;">) for main activity and type the following code.</span></div>
<div style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">
Here <strong>FrameLayout</strong> is used to replace the main content using <strong>Fragments</strong> and it should be always the first child of the layout for z-index purpose.</div>
<div style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">
3.<strong style="color: #383838;">list_item_bg_normal.xml </strong><span style="color: #383838;">and </span><strong style="color: #383838;">list_item_bg_pressed.xml </strong><span style="color: #383838;">represents </span><span style="color: #383838;">list item state when normal and pressed.</span></div>
<div style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">
<span style="color: #383838;">4. </span><span style="color: #383838;">Created another xml file to combine both the drawable states under </span><strong style="color: #383838;">res ⇒ drawable</strong><span style="color: #383838;"> named </span><strong style="color: #383838;">list_selector.xml</strong></div>
<div style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">
<span style="color: #383838;">5.</span><strong style="color: #383838;">counter_bg.xml </strong><span style="color: #383838;">used</span><strong style="color: #383838;"> </strong><span style="color: #383838;">for rounde corner background for the counter value.</span></div>
<div style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">
<span style="color: #383838;">6. </span><span style="color: #383838;">As listview has the custom layout, we need another layout file which defines the each list row. So create a layout file under </span><strong style="color: #383838;">res ⇒ layout</strong><span style="color: #383838;"> named </span><strong style="color: #383838;">drawer_list_item.xml</strong><span style="color: #383838;">. This is a relative layout which places the icon, title and counter relative to one another.</span></div>
<div style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">
<span style="color: #383838;">7. In </span><strong style="color: #383838;">NavDrawerItem.java, </strong><strong style="color: #383838;">isCounterVisible </strong><span style="color: #383838;">defines the visibility of the counter value.</span></div>
<div style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">
<span style="color: #383838;">8. in </span><strong style="color: #383838;">MainActivity.java, invalidateOptionMenu()</strong><span style="color: #383838;"> is called in </span><strong style="color: #383838;">onDrawerOpened()</strong><span style="color: #383838;"> and </span><strong style="color: #383838;">onDrawerClosed()</strong><span style="color: #383838;"> to hide and show the action bar icons on navigation drawer opened and closed.</span></div>
</div>
Anonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.com0tag:blogger.com,1999:blog-6553455441370131395.post-68070803783866595412013-12-26T12:24:00.000-08:002013-12-26T12:29:49.903-08:00Simple Fragments with Action Bar Example in Android 2.2, android:minSdkVersion="8",<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: #f9f9f9; font-family: Courier New, Courier, monospace; font-size: large; line-height: 32px;"><a href="https://drive.google.com/file/d/0B7370Q3RTbaSajRQMmNsdUpBb28/edit?usp=sharing" style="background-color: #f9f9f9; line-height: 32px;" target="_blank">Download</a>(</span><span style="color: #222222; font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px;">File->Download</span><span style="background-color: #f9f9f9; font-family: 'Courier New', Courier, monospace; font-size: large; line-height: 32px;">)</span><br />
<span style="background-color: #f9f9f9; color: #222222; font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>
<span style="background-color: #f9f9f9; color: #222222; font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px;">import it in eclipse if it having issues then follow the steps:</span><br />
<span style="background-color: #f9f9f9; color: #222222; font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>
<span style="background-color: #f9f9f9; color: #222222; font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px;">Setup the Android Support Libraries in your development project </span><br />
<span style="background-color: #f9f9f9; font-family: Roboto, sans-serif; line-height: 32px;"><b><span style="color: red;"><a href="http://developer.android.com/tools/support-library/setup.html" target="_blank">Support Library Setup</a></span></b></span><br />
<span style="background-color: #f9f9f9; font-family: Roboto, sans-serif; line-height: 32px;"><b>1. </b>In eclipse File->Import>Existing Projects into workspace</span><br />
<span style="background-color: #f9f9f9; font-family: Roboto, sans-serif; line-height: 32px;">Select a root directory-></span><br />
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;">C:\Program Files\Android\android-sdk\extras\android\support\v7\appcompat</span></span><br />
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;"><br /></span></span>
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;">2. add compatible library to your project.</span></span><br />
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;">Right click on your project ->Properties->Android->Library->add</span></span><br />
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;">select the V7 lib which you have imported in step 1.</span></span><br />
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;"><br /></span></span>
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;">3. Build and run.</span></span><br />
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;"><br /></span></span>
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;"><br /></span></span>
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;"><br /></span></span>
<br />
<span style="background-color: #f9f9f9; line-height: 32px;"><span style="font-family: Roboto, sans-serif;"><br /></span></span></div>
Anonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.com13tag:blogger.com,1999:blog-6553455441370131395.post-78173715704501213892013-12-26T11:39:00.002-08:002013-12-27T00:29:36.605-08:00Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://drive.google.com/file/d/0B7370Q3RTbaSclBsb0xja2dhWUk/edit?usp=sharing" style="font-family: 'Open Sans', sans-serif; font-size: x-large; line-height: 25px; text-align: justify;" target="_blank">Download Code</a>(download zip, file->download)<br />
<br />
<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">You can go through the</span><span style="color: red;"><span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"> </span><span style="color: red;"><a href="http://developer.android.com/guide/google/gcm/index.html" target="_blank">official documentation</a></span></span><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"> if you want to know more about GCM.</span><br />
<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><br /></span>
<span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><span style="color: orange;"><b>1</b>. How to enable the GCM Service</span></span><br />
<span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><span style="color: orange;"><br /></span></span><span style="background-color: white; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><b>1.1</b>. </span><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">Goto</span><span style="background-color: white; color: red; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"> </span><span style="color: #38761d;"><span style="background-color: white; border: none; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify; text-decoration: none;"><a href="https://code.google.com/apis/console" target="_blank">Google APIs Console pag</a></span><span style="background-color: white; border: none; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify; text-decoration: none;"><a href="https://code.google.com/apis/console" target="_blank">e</a></span></span><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"> and create a new project.</span><br />
<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><b>1.2</b>. Create a new Project.</span><br />
<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><b>1.3</b>. </span><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">After creating project you can see the </span><strong style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">P</strong><strong style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">roject Number in the following image</strong><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">. Note down the project id which will be used as </span><span style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(225, 225, 232); font-family: 'Open Sans', sans-serif; font-size: 15px; font-weight: 600; letter-spacing: 1.5px; line-height: 25px; padding: 2px 4px; text-align: justify;"><span style="color: lime;">SENDER ID</span></span><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"> in android project. </span><br />
<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ls3nVmT1Kk07CdLEl0rA7zcz_uYiorfSWZrlr2KvlckCB8cbzLKV4Ol39uAanNvGALi8syz-PskV2BFEETVDiCTxRQXjtBCMh0WAh-PZSOWMnKf5hli09mLh001Jo622PkwH9BNbHfc/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ls3nVmT1Kk07CdLEl0rA7zcz_uYiorfSWZrlr2KvlckCB8cbzLKV4Ol39uAanNvGALi8syz-PskV2BFEETVDiCTxRQXjtBCMh0WAh-PZSOWMnKf5hli09mLh001Jo622PkwH9BNbHfc/s1600/1.png" height="151" width="400" /></a></div>
<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><b>1.4</b>. After that, Click on APIs & auth and turn on</span><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"> </span><span style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(225, 225, 232); font-family: 'Open Sans', sans-serif; font-size: 15px; font-weight: 600; letter-spacing: 1.5px; line-height: 25px; padding: 2px 4px; text-align: justify;"><span style="color: lime;">Google Cloude Messaging for android </span></span><span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"> .</span><br />
<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><b>1.5</b>. After that, Click on Credencials from left pannel.<br /><b>1.6</b>. You can see the </span><b>OAuth and Public API access.</b><br />
<div style="text-align: justify;">
1.7. <span style="font-family: Open Sans, sans-serif;"><span style="font-size: 15px; line-height: 25px;"><span style="color: #383838;">Click on </span><span style="background-color: red;"><span style="color: white;">CREATE NEW CLIENT ID </span></span></span></span></div>
<div style="text-align: justify;">
<span style="color: #383838; font-family: Open Sans, sans-serif;"><span style="font-size: 15px; line-height: 25px;">choose a option </span></span><span style="text-align: left;">Client ID for web application, Click ok.</span></div>
<div style="text-align: justify;">
<span style="text-align: left;">1.8 After, Click <span style="background-color: red;"><span style="color: white;">C REATE NEW KEY</span></span></span></div>
<div style="text-align: left;">
<span style="background-color: white;">Choose a option </span>Key for browser applications,Click ok.</div>
<div style="text-align: left;">
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgygEFBQ4yKFFeLv9-CAMFrwjgfKyFtIPiO5ix4g1Xeu6WhkfH24c70dKAT1yi5xYa_wRB0WZn_LChTpwEWrJUQCV3H5JjcZLbZw9y3VQAtAQpAnCJ3Z74O5l9NmTnyKDDFcpLFKN9X5cE/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgygEFBQ4yKFFeLv9-CAMFrwjgfKyFtIPiO5ix4g1Xeu6WhkfH24c70dKAT1yi5xYa_wRB0WZn_LChTpwEWrJUQCV3H5JjcZLbZw9y3VQAtAQpAnCJ3Z74O5l9NmTnyKDDFcpLFKN9X5cE/s1600/1.png" height="250" width="400" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<br />
1.9 API key-<span style="background-color: white; color: #383838; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;">This API key will be used when sending requests to GCM server.</span><br />
<br /></div>
<div style="text-align: left;">
<span style="background-color: white; color: orange; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px; text-align: justify;"><b>2</b>. Creating android project.</span></div>
<div style="text-align: justify;">
<span style="font-family: Open Sans, sans-serif;"><span style="color: orange; font-size: large; line-height: 25px;"><a href="https://drive.google.com/file/d/0B7370Q3RTbaSclBsb0xja2dhWUk/edit?usp=sharing" target="_blank">Download Code</a></span></span><br />
<span style="font-family: Open Sans, sans-serif;"><br /></span>
<span style="font-family: Open Sans, sans-serif;">File->Dowload or press CTRL+S</span></div>
<div style="text-align: justify;">
<span style="font-family: Open Sans, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Open Sans, sans-serif;">2.1 import this downloaded source code in eclipse.</span></div>
<div style="text-align: left;">
<span style="font-family: Open Sans, sans-serif;">2.2. open </span><span style="text-align: left;"><span style="font-family: Open Sans, sans-serif;"><b>CommonUtilities.java, </b>and give the parameters, </span></span></div>
<div style="text-align: left;">
<span style="text-align: left;"><span style="font-family: Open Sans, sans-serif;"><b>SERVER_URL="your php file link";</b></span></span></div>
<div style="text-align: left;">
<span style="text-align: left;"><span style="font-family: Open Sans, sans-serif;"><b>SENDER_ID="This is your Project Number check it in above image1";</b></span></span></div>
<div style="text-align: left;">
<span style="text-align: left;"><span style="font-family: Open Sans, sans-serif;">2.3<b> </b>Debug the app.</span></span><br />
<span style="text-align: left;"><span style="font-family: Open Sans, sans-serif;">2.4 During registration we are posting three parameters, </span></span><span style="font-family: Open Sans, sans-serif;"><i><b>regId, name, email.</b></i></span><br />
<span style="font-family: Open Sans, sans-serif;"><i><b>regId is the id generated by GCM Server.</b></i></span><br />
<span style="font-family: Open Sans, sans-serif;"><i>2.5 </i>You<i> </i>can check the regId in logcat.</span><br />
<span style="text-align: left;"><span style="font-family: Open Sans, sans-serif;"><b><br /></b></span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: orange; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 25px;"><b>3</b>. PHP code.</span></div>
<span style="font-family: Courier New, Courier, monospace;"><span style="line-height: 14px; white-space: pre;"><i></i></span></span><br />
<div style="color: grey;">
<span style="font-family: Courier New, Courier, monospace;"><span style="line-height: 14px; white-space: pre;"><i><span style="color: grey; font-family: Courier New, Courier, monospace;"><span style="line-height: 14px; white-space: pre;"><i><br /></i></span></span></i></span></span></div>
<span style="font-family: Courier New, Courier, monospace;"><span style="line-height: 14px; white-space: pre;"><i>
<span style="color: red;"><?php</span></i></span></span><br />
<div>
<span style="color: grey; font-family: Courier New, Courier, monospace;"><span style="line-height: 14px; white-space: pre;"><i><br /></i></span></span><span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;">/**</span><br />
<span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;"> * The following function will send a GCM notification using curl.</span><br />
<span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;"> * </span><br />
<span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;"> * @param $apiKey [string] The Browser API key string for your GCM account</span><br />
<span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;"> * @param $registrationIdsArray [array] An array of registration ids to send this notification to</span><br />
<span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;"> * @param $messageData [array] An named array of data to send as the notification payload</span><br />
<span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;"> */</span><br />
<div>
<span style="color: grey; font-family: Courier New, Courier, monospace;"><span style="line-height: 14px; white-space: pre;"><i><br /></i></span></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-weight: bold; line-height: 14px; white-space: pre;">function</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> sendNotification</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$apiKey</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$registrationIdsArray</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$messageData</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><br />
<span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">{</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$headers</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><a href="http://www.php.net/array" style="background-color: white; color: #60bddb; font-family: 'Courier New', Courier, monospace; line-height: 14px; text-decoration: none; white-space: pre;"><span style="color: #000066;">array</span></a><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"Content-Type:"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> . </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"application/json"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"Authorization:"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> . </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"key="</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> . </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$apiKey</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$data</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><a href="http://www.php.net/array" style="background-color: white; color: #60bddb; font-family: 'Courier New', Courier, monospace; line-height: 14px; text-decoration: none; white-space: pre;"><span style="color: #000066;">array</span></a><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">'data'</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> => </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$messageData</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">,</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">'registration_ids'</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> => </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$registrationIdsArray</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = curl_init</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> curl_setopt</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, CURLOPT_HTTPHEADER, </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$headers</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">; </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> curl_setopt</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, CURLOPT_URL, </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"https://android.googleapis.com/gcm/send"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> curl_setopt</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, CURLOPT_SSL_VERIFYHOST, </span><span style="background-color: white; color: #cc66cc; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">0</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> curl_setopt</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, CURLOPT_SSL_VERIFYPEER, </span><span style="background-color: white; color: #cc66cc; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">0</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> curl_setopt</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, CURLOPT_RETURNTRANSFER, </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-weight: bold; line-height: 14px; white-space: pre;">true</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> curl_setopt</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, CURLOPT_POSTFIELDS, json_encode</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$data</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$response</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = curl_exec</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> curl_close</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$ch</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #b1b100; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">return</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$response</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">}</span><br />
<span style="background-color: white; color: grey; font-family: 'Courier New', Courier, monospace; font-style: italic; line-height: 14px; white-space: pre;">// Message to send</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$message</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"the test message"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$tickerText</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"ticker text message"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$contentTitle</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"content title"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$contentText</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"content body"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$registrationId</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">'DEVICE_ID'</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$apiKey</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"YOUR_BROWSER_API_KEY"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<br />
<span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$response</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> = sendNotification</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$apiKey</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><a href="http://www.php.net/array" style="background-color: white; color: #60bddb; font-family: 'Courier New', Courier, monospace; line-height: 14px; text-decoration: none; white-space: pre;"><span style="color: #000066;">array</span></a><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$registrationId</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><a href="http://www.php.net/array" style="background-color: white; color: #60bddb; font-family: 'Courier New', Courier, monospace; line-height: 14px; text-decoration: none; white-space: pre;"><span style="color: #000066;">array</span></a><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">(</span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">'message'</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> => </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$message</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">'tickerText'</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> => </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$tickerText</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">'contentTitle'</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> => </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$contentTitle</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">, </span><span style="background-color: white; color: red; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">"contentText"</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> => </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$contentText</span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: #66cc66; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">)</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<br />
<a href="http://www.php.net/echo" style="background-color: white; color: #60bddb; font-family: 'Courier New', Courier, monospace; line-height: 14px; text-decoration: none; white-space: pre;"><span style="color: #000066;">echo</span></a><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;"> </span><span style="background-color: white; color: blue; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">$response</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 14px; white-space: pre;">;</span><br />
<div style="text-align: justify;">
<span style="color: orange; font-family: Open Sans, sans-serif;"><span style="font-size: 15px; line-height: 25px;">?></span></span></div>
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.com1tag:blogger.com,1999:blog-6553455441370131395.post-83726001935661239742012-02-17T22:20:00.000-08:002014-04-27T04:48:05.726-07:00Retrieve the data from MySQL and display in listview android<div dir="ltr" style="text-align: left;" trbidi="on">
Download the Demo Project From Following link and import it in your eclipse ide.<br />
<br />
read the instruction in ReadMe.txt file...<br />
<br />
if any question plz leave a comment.<br />
<span class="Apple-style-span" style="color: #990000; font-size: large;"><b><a href="https://drive.google.com/file/d/0B7370Q3RTbaSeVhKSEpJby0weVU/edit?usp=sharing" target="_blank">Download</a></b></span><br />
<span class="Apple-style-span" style="color: #990000; font-size: large;">or</span><br />
<a href="http://www.4shared.com/zip/W-FITh_h/demophpmysql.html" target="_blank"><span class="Apple-style-span" style="color: #990000; font-size: large;"><b>Download</b></span></a></div>
Anonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.com20Karnataka, India16.806618942940936 73.90916906250004112.893463442940936 68.745595062500044 20.719774442940935 79.072743062500038tag:blogger.com,1999:blog-6553455441370131395.post-3550023978903347662010-10-31T03:22:00.000-07:002012-12-27T11:45:22.108-08:00Running Turbo C++ Compiler in Win 7 64 bit using DOSBox<div dir="ltr" style="text-align: left;" trbidi="on">
In this article i will discuss about running Turbo c++ compiler in Windows 7 64 bit OS .<br />
TC++ compiler is a 16 bit software and cannot be run on 64 bit versions of Windows 7.But TC ++ can be run in 64 bit Windows 7 by using an x86 emulator called DOS Box.<br />
<br />
The process of doing thos is detailed below in plain text or You can see the youtube video which i have attached.OR for better quality click following link.<br />
<a href="http://www.youtube.com/watch?v=NqgBp8i-sik"><span class="Apple-style-span" style="color: red;">http://www.youtube.com/watch?v=NqgBp8i-sik</span></a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<span class="Apple-style-span" style="font-size: x-large;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dxsid4qXSXASyvWU15DViWypd-h1gXnHB01ITgQNao3ysahJ59Nz5wsfvz31uM-SD3B1nVmh4w2VBMurtlArA' class='b-hbp-video b-uploaded' frameborder='0'></iframe></span></div>
<br />
<a href="http://www.youtube.com/watch?v=NqgBp8i-sik"></a><br />
<br />
1)Download and install latest version of DOSBox from www.dosbox.com<br />
<br />
or direct link available for DoxBox0.74 is here...<br />
<a href="http://www.mediafire.com/?sfpq4h1206ew06f">http://www.mediafire.com/?sfpq4h1206ew06f</a><br />
<br />
<br />
2)Open DOSBox<br />
<br />
<br />
A console window will open type in the following commands by refering the details given below it<br />
____________________________________________________________________<br />
mount c h:\<br />
h:<br />
cd tc<br />
cd bin<br />
tc<br />
____________________________________________________________________<br />
** Here "c" refers to a virtual drive you can specify any alphabet you like it doesn't matter.<br />
** "h:\ " Refers to the drive which you contain the TC Program folder<br />
** "cd tc " command is used to change the active directory to the folder named tc which contains tc.exe and other files if you have changed the orginal name of this folder use that name instead of tc in this command.<br />
<br />
3)TC will open open Options>Directories replace drive letters of all directory specifications by the drive letter you specified earlier in my case "c".<br />
Now you can start doing your program in yur beloved Borland compiler</div>
Anonymoushttp://www.blogger.com/profile/17047264830632614786noreply@blogger.com39