12

好吧,我看到很多人只是通过说来驳回这个问题

“它是为操作系统组件保留的”

“它需要访问源代码”

好吧,我可以访问源代码,并且可以将我想要的任何应用程序或小部件设置为系统应用程序。那么现在我将如何让我的小部件在右侧显示其通知?

编辑:好的,人们正朝着错误的方向前进,所以我在这里添加上下文。. . 看看你的手机。. . 你一直在手机右侧看到Wi-Fi信号和电话信号。我希望我的信号也在那里显示。. . 连同系统信号。. 我公司正在制造的平板电脑中有一个新的硬件芯片,我必须像手机信号一样不断地显示它的信号强度。它将被集成到平板电脑的 Android 源代码中。

4

5 回答 5

7

您可能需要参考手机状态栏的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

这不是一件容易的事,因为你必须自己添加很多东西。

于 2013-12-10T09:39:09.753 回答
2

您需要修改几个地方:

framework/base/core/res/res/values/config.xml,添加一个槽: <string-array name="config_statusBarIcons">

然后是frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java:

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

大部分就是这样,我相信你可以通过一些试验和错误自己找出其余的。

于 2014-09-23T16:19:44.843 回答
0

我有一个简单的想法,即:

在清单中,将 android 屏幕方向声明为横向,并将纵向模式设计为​​横向,以便您的应用在横向模式下看起来是纵向的。

于 2013-08-21T06:34:05.577 回答
-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);
        }
于 2013-08-21T06:16:50.440 回答
-1

我在这个论坛上找到了一些关于你的问题的相关信息......

http://forum.kde.org/viewtopic.php?t=107601

- 再会

于 2013-08-21T06:17:24.387 回答