2013-09-04 4 views
0

Android 앱을 만들었습니다. 기기에 설치되면 GUI 부분이 표시되지 않기를 바랍니다. 서버에서 메시지를 브로드 캐스트 할 때 알림 선택시 사용자가 GUI 부분을 표시하도록합니다. 어떻게해야합니까? Android? 우리는 어떻게 활동의 테마를 프로그래밍 방식으로 바꿀 수 있습니까

나는 내가 내 Manifest.XML에 파일을
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()); 
    } 
+0

에서 예를 들어

를받을 때 업데이트되는 변수 INT? –

+0

실제로 GCM을 사용하는 aap을 만들고 있습니다. 따라서 해당 앱을 설치 한 후 서버에서 알림을 보내면 활동이 시작됩니다. – Developer

+0

매니페스트 코드와 알림이 포함 된 코드를 게시 할 수 있습니까? 기능? –

답변

0

가 생성이 방법을 시도 하나의 공용 정적 통지는 브로드 캐스트 리시버를 사용하는 수신기 클래스

public static int THEME = 0; 
onReceive(){ 

    if(cond1){ 
     THEME = R.style.them1; 
    }else if(cond2){ 
     THEME = R.style.them2; 
    } 

} 




@Override 
    protected void onCreate(Bundle savedInstanceState) { 

       if(THEME!=0){ 
       setTheme(THEME); 
       } 

     super.onCreate(savedInstanceState); 
+0

이 앱을 설치할 때 UI가 표시됩니다. 설치시 UI가 필요하지 않습니다. 앱이 알림을 받고 알림 선택시 UI를 표시하려고합니다. APP의 – Developer

관련 문제