1

Androidのステータスバーに情報を表示したい。しかし、通知に何も表示したくありません。しかし、ステータスバーを下にドラッグして通知バーを見ると、通知用の空の場所が表示されます。誰かがたまたま通知バーに通知用のこの空の場所を表示しないようにするにはどうすればよいですか?

このリンクhttp://developer.android.com/reference/android/app/Notification.htmlを読み、幅と高さがゼロで通知画像とテキストのないカスタム通知レイアウトを作成しようとしました。しかし、それは役に立ちませんでした。通知バーに空の通知領域がまだ表示されます。

これはカスタム通知レイアウトです

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="0dp" >
</RelativeLayout>

これは私のコード膨張通知です

public class BatteryStatusBarActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final int HELLO_ID = 1;

    //Get a reference to the NotificationManager:
     String ns = Context.NOTIFICATION_SERVICE;
     NotificationManager mNotificationManager = (NotificationManager)getSystemService(ns);

    //Instantiate the Notification:
    int icon = R.drawable.notification_icon;
    CharSequence tickerText = "Hello";
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, tickerText, when);

    //Define the notification's message and PendingIntent:
    Context context = getApplicationContext();
    Intent notificationIntent = new Intent(this, BatteryStatusBarActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.setLatestEventInfo(context, tickerText, tickerText, contentIntent);
    // redefine content view for notification
    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
    notification.contentView = contentView;

    //Pass the Notification to the NotificationManager:
    mNotificationManager.notify(HELLO_ID, notification);

    //mNotificationManager.cancel(HELLO_ID);    
}
}
4

0 に答える 0