dtkmejg127475 2014-07-13 14:38
浏览 32
已采纳

将我的GCM代码添加到现有应用程序中

I am using the code http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ It is running well for multicast too.I want to remove the user registration activity from the app and integrate it into my existing app.How to do that? The GCM is taking email id and name from the users.I don't want this to happen.

  • 写回答

1条回答 默认 最新

  • dourao1968 2014-07-13 14:52
    关注

    Looking at the app you linked to, the RegisterActivity is the first activity started when the app is launched, and it doesn't do anthing beside asking for email and name, and starting the MainActivity.

    You can simply remove this activity and start the app from the MainActivity. That means you should add the following intent-filter to the declaration of MainActivity in the manifest, and remove the declaration of RegisterActivity.

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    

    In the code of MainActivity.onCreate you should remove any reference to email and name (which are currently passed to it from the RegisterActivity). The registration to GCM is already done in the MainActivity, so you don't have to change anything there.

    That said, you are basing your app on an old tutorial (from 2012) which uses a deprecated class (GCMRegistrar) to register to GCM. You should look at the current official GCM Demo app to see how the current way of registration looks like. It's simpler.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊