2013-08-21 50 views
11

好吧,我看到很多人只是解僱了這個問題,說如何在右側創建通知狀態欄圖標?

「這是保留給OS組件」

「它需要訪問源」

嗯,我有機會獲得源和我可以設置任何應用程序或小部件,我想作爲一個系統應用程序。那麼現在我該如何才能讓我的widget在右側顯示它的通知?

編輯: 好吧脂肪酶會進入錯誤的方向,所以生病在這裏添加上下文。 。 。 看着你的手機。 。 。你一直看到電話右側的Wi-Fi信號和電話信號。我希望我的信號在那裏顯示。 。 。以及系統信號。 。我公司生產的平板電腦中有一個新的硬件芯片,我必須像電話信號一樣持續顯示其信號強度。它將被整合到平板電腦的Android資源中。

+0

你在說如何製作Android TABLET風格的狀態欄嗎? – Robin

+0

沒有。 。 。看看你的手機。 。 。你一直在電話右側看到wifi信號和電話信號。我希望我的信號在那裏顯示。 。 。以及系統信號。 。我公司生產的平板電腦中有一個新的硬件芯片,並且可以像電話信號一樣持續顯示其信號強度。它將被整合到android源代碼中。 –

+0

這麼多意見和沒有答案。 。 。有人可以投票的問題,讓人們覺得有必要回答嗎?或者賞金事情如何工作? –

回答

6

您可能需要參考的手機狀態欄的Android源代碼的代碼,在https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r3.1/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

,並採取看看方法,如

addIcon 
updateIcon 
removeIcon 

,因爲你有這不是一件容易的事自己添加大量的東西。

+0

最後一個好主角。 。 TNX隊友:) –

+0

@PrinceChampappilly這個答案的任何進展? vallathum nadakkumo? –

+0

@VishnudevK vallathum nadakuvo ennu chodicha。 。 。這是答案。 。 。但是你需要在android框架中添加自定義監聽器。我所做的是拉下雙SIM卡手機的代碼,並用我的自定義通知替換第二個SIM卡信號通知。 。這樣我只需要在代碼中編輯該實例。我沒有完成整個過程。 。 。我被重新分配到另一個項目中途。 –

-1
public class GCMIntentService extends GCMBaseIntentService { 

public static final String PROJECT_ID = "4898989797"; 
private static final String TAG = "GCMIntentService"; 
ModelNotificationMessage modelNotificationMessage; 

public GCMIntentService() { 
    super(PROJECT_ID); 
    Log.d(TAG, "GCMIntentService init"); 
} 

@Override 
protected void onError(Context ctx, String sError) { 
    // TODO Auto-generated method stub 
    Log.d(TAG, "Error: " + sError); 

} 

@Override 
protected void onMessage(Context ctx, Intent intent) { 

    Log.d(TAG, "Message Received"); 

    String message = intent.getStringExtra("message"); 

    Log.d(TAG, "Message Received" + message); 

    sendNotification(message); 
    Intent broadcastIntent = new Intent(); 
    broadcastIntent.setAction("GCM_RECEIVED_ACTION"); 

    broadcastIntent.putExtra("gcm", message); 

    ctx.sendBroadcast(broadcastIntent); 
} 




private void sendNotification(String message) { 
      // this 
      String ns = Context.NOTIFICATION_SERVICE; 
      NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); 

      int icon = R.drawable.notification; 
      CharSequence tickerText = message; // ticker-text 
      long when = System.currentTimeMillis(); 
      Context context = getApplicationContext(); 
      CharSequence contentTitle = modelNotificationMessage.getKey(); 
      CharSequence contentText = message; 
      Intent notificationIntent = null; 
      int NOTIFICATION_ID = 9999; 



       NOTIFICATION_ID = CommonVariable.notification_message; 
       notificationIntent = new Intent(this, ViewMessages.class); 
       contentText = arrayList.get(0).getDescription(); 
       tickerText = arrayList.get(0).getDescription(); 

      // and this 
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0, 
        notificationIntent, 0); 
      Notification notification = new Notification(icon, tickerText, when); 
      // Play default notification sound 
      notification.defaults |= Notification.DEFAULT_SOUND; 
      notification.setLatestEventInfo(context, contentTitle, contentText, 
        contentIntent); 
      mNotificationManager.notify(NOTIFICATION_ID, notification); 
     } 
+0

這不是他正在尋找的,他希望通知欄中的圖標顯示在右側。 –

+0

通知通知=新通知(icon,tickerText,何時); 請在上面的代碼中找到此行。此行是在狀態欄中顯示通知的圖標。 – dipali

+0

這將創建一個默認通知,請查看http://developer.android.com/reference/android/app/Notification.html –

0

我有一個簡單的想法,即:

在清單宣佈Android屏幕方向爲風景 ,並且設計爲肖像模式風景 所以你的應用程序在橫向模式下看起來像。

+0

:好主意。它工作得很好。謝謝 – ArunMak

+0

哈哈。 。這僅適用於應用程序內部。 。 。我希望這可以在按下按鈕的按鈕上工作,以便即使在主頁上也可以看到它。 。 。很好的技巧btw:P –

+0

你需要在某種程度上修改Android操作系統,但由於Android是開源的,這不是問題。 問題是讓它安裝在手機上 - 如果你已經注意到,唯一擁有自定義用戶界面的公司也是手機制造商,所以他們可以隨手機一起發貨。 – Ruban

2

你需要修改幾個地方:

框架/基/核心/ RES/RES /價值/ config.xml文件中,添加一個槽: <string-array name="config_statusBarIcons">

然後框架/基/包/ systemUI/src目錄/ COM /安卓/ systemui /狀態欄/電話/ PhoneStatusBarPolicy.java:

mService.setIcon("<your slot name>", R.drawable.yourlogo, 0, null); 
mService.setIconVisibility("<your slot name>", setVisible); 

這主要是它,我敢肯定,你可以計算出其餘的你自己的一些試錯。

相關問題