0
Android
앱을 만들었습니다. 기기에 설치되면 GUI 부분이 표시되지 않기를 바랍니다. 서버에서 메시지를 브로드 캐스트 할 때 알림 선택시 사용자가 GUI 부분을 표시하도록합니다. 어떻게해야합니까? Android
? 우리는 어떻게 활동의 테마를 프로그래밍 방식으로 바꿀 수 있습니까
setTheme(android.R.style.Theme);
이 새로운 Intent
Notification
기능이 시도
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.iween.gcmclient" android:versionCode="1" android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17"/>
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.example.iween.gcmclient.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.example.iween.gcmclient.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Main activity. -->
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.example.iween.gcmclient.DemoActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.example.iween.gcmclient.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.google.android.gcm.demo.app" />
</intent-filter>
</receiver>
<service android:name="com.example.iween.gcmclient.GcmIntentService" />
</application>
</manifest>
알림 기능
private void sendNotification(String recivedMessage) {
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, DemoActivity.class), 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_gcm)
.setContentTitle("Iween Notification")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(recivedMessage))
.setContentText(recivedMessage);
mBuilder.build().flags = Notification.FLAG_AUTO_CANCEL;
Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(notificationSound);
mBuilder.setAutoCancel(true);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
에서 예를 들어
를받을 때 업데이트되는 변수 INT? –
실제로 GCM을 사용하는 aap을 만들고 있습니다. 따라서 해당 앱을 설치 한 후 서버에서 알림을 보내면 활동이 시작됩니다. – Developer
매니페스트 코드와 알림이 포함 된 코드를 게시 할 수 있습니까? 기능? –