2013-08-21 52 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); 

这主要是它,我敢肯定,你可以计算出其余的你自己的一些试错。

相关问题