我无法在我的虚拟设备android

时间:2017-07-14 20:22:15

标签: android firebase push-notification avd

我之前在我的vritual设备中收到了它...但是在我从AVD卸载并重新安装我的应用程序后,我没有得到任何消息但在firebase控制台中显示已完成状态..plz有人帮助我

This is Main Activity 

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageButton budbtn=(ImageButton)findViewById(R.id.buddies);
        budbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent= new Intent(MainActivity.this,BuddiesAct.class);
                startActivity(intent);
            }
        });
        ImageButton prim=(ImageButton)findViewById(R.id.primary);
        ImageButton senior=(ImageButton)findViewById(R.id.senior);
        ImageButton suprsen=(ImageButton)findViewById(R.id.supersenior);
    }
}

Project level built gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.example.zion.kidskount"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    apply plugin: 'com.google.gms.google-services'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'gr.pantrif:easy-android-splash-screen:0.0.1'
    compile 'com.google.firebase:firebase-messaging:9.0.0'

    testCompile 'junit:junit:4.12'
}

1 个答案:

答案 0 :(得分:0)

每次重新安装或清除应用程序的数据时,都会再次生成token

每次按照here所述调用onTokenRefresh()时记录您的令牌。

因此,获取您的令牌并使用它发送推送通知:D