我一直试图通过Parse获取通知,根据它发送通知的页面,但模拟器什么也得不到。请帮忙:(
我的班级
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.parse.Parse;
import com.parse.ParseInstallation;
import com.parse.PushService;
public class FARQ_UANL extends ActionBarActivity {
private int cont=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_farq__uanl);
//Parse
Parse.initialize(this, "key", "key");
PushService.setDefaultPushCallback(this, FARQ_UANL.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
final WebView myWebView = (WebView) this.findViewById(R.id.pagweb);
myWebView.loadUrl("http://www.arquitectura.uanl.mx/");
Button btn1 = (Button) findViewById(R.id.home);
Button btn2 = (Button) findViewById(R.id.calendario);
Button btn3 = (Button) findViewById(R.id.buzon);
Button btn4 = (Button) findViewById(R.id.mapa);
Button btn5 = (Button) findViewById(R.id.directorio);
Button btn6 = (Button) findViewById(R.id.faq);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myWebView.loadUrl("http://www.arquitectura.uanl.mx/");
cont++;
if(cont==6) {
//toast
Toast tostito =
Toast.makeText(getApplicationContext(),
"Bienvenido al infierno", Toast.LENGTH_SHORT);
tostito.show();
}
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myWebView.loadUrl("http://www.arquitectura.uanl.mx/calendario.html");
cont=0;
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myWebView.loadUrl("http://arquitectura.uanl.mx/buzondesugerencias.html");
cont=0;
}
});
btn4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myWebView.loadUrl("http://arquitectura.uanl.mx/instalaciones.html");
cont=0;
}
});
btn5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myWebView.loadUrl("http://arquitectura.uanl.mx/directorio.html");
cont=0;
}
});
btn6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myWebView.loadUrl("http://arquitectura.uanl.mx/informacion.html#faq");
cont=0;
}
});
}
}
android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="karudia.com.farq" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="karudia.com.farq.permission.C2D_MESSAGE" />
<uses-permission android:name="karudia.com.farq.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/iniciales"
android:theme="@style/AppTheme" >
<activity
android:name=".FARQ_UANL"
android:label="@string/iniciales" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="karudia.com.farq" />
</intent-filter>
</receiver>
</application>
如果有人知道使用推送通知的方式,请告诉我
答案 0 :(得分:0)
这部分是你的Application类的onCreate方法
//Parse
Parse.initialize(this, "key", "key");
PushService.setDefaultPushCallback(this, FARQ_UANL.class);
ParseInstallation.getCurrentInstallation().saveInBackground();