12

Ok I saw a lot of people just dismiss this question by saying

"it's reserved for OS component "

"it requires access to source"

Well I have access to the source and I can set any app or widget I want as a system app. So now how would I go about making my widget show its notification on the right side?

EDIT: ok ppl are going in the wrong direction so ill add come context here . . . look at ur phone . . . u see Wi-Fi signal and phone signal on the right side of the phone all the time right. I want my signal to be shown there aswell . . . along with the system signals . . I have a new hardware chip in the tablet my company is making and I have to display its signal strength constantly just like the phone signal. It is going to be integrated into the Android source of the tablet.

Prince Champappilly
  • 303
  • 1
  • 7
  • 29
  • Are you talking about how to make an Android TABLET style status bar? – Robin Aug 21 '13 at 08:09
  • No . . . look at ur phone . . . u see wifi signal and phone signal on the right side of the phone all the time right. I want my signal to be shown there aswell . . . along with the system signals . . I have a new hardware chip in the tablet my company is making and ive to display its signal strength constantly just like the phone signal. it is going to be integrated into the android source. – Prince Champappilly Aug 21 '13 at 08:41
  • so many views and no answer . . . can someone up vote the question so that people feel the need to answer it ?? or how does the bounty thing work ?? – Prince Champappilly Dec 10 '13 at 06:51
  • Hey if you've figure this out please share a snippet – Zen May 05 '14 at 01:22
  • Google Japanese Input displays A or あ icon on the right side. It is not a system application, but just a normal application you can download from the Play Store. It worked both on a 4.4.2 Samsung device and on a 5.1.1 Nexus device. So there must be some kind of API. – Damn Vegetables May 21 '15 at 07:02

5 Answers5

7

You might need to refer to the code of Android source code of phone status bar, at https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r3.1/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

And take a look at the methods like

addIcon
updateIcon
removeIcon

It is not easy task since you have to add lots of stuff by yourself.

Robin
  • 10,052
  • 6
  • 31
  • 52
  • Finally a Good Lead . . tnx mate :) – Prince Champappilly Dec 10 '13 at 10:42
  • @PrinceChampappilly any progress with this answer? vallathum nadakkumo? – Vishnudev K Jun 30 '14 at 13:16
  • @VishnudevK vallathum nadakuvo ennu chodicha . . .Yes this is the answer . . . But u need to add ur custom listener in the android framework. What I did was pull down the code for a dual sim phone and replace the 2nd sims signal notification with my custom notification . . that way I just needed to edit that instance across the code. I didn't complete the whole process . . . I was reassigned to another project half way through. – Prince Champappilly Jul 03 '14 at 08:42
  • I want to ask how did you answer this question? I mean did you studied whole android source code or you used a tool to search through the code? – VSB Aug 02 '16 at 17:39
  • @VSB Hi. Do you now know the answer to that question? – Edw590 May 03 '21 at 10:30
  • 1
    @DADi590 it is a long time ago. Unfortunately, I could not check or remember. – VSB May 03 '21 at 12:13
2

You'll need to modify a few places:

framework/base/core/res/res/values/config.xml, add a slot in: <string-array name="config_statusBarIcons">

then 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);

That's mostly it, I'm sure you can figure out the rest on your own with some trial and errors.

0

I have one easy idea ie:

In manifest declare android screen orientation as landscape and design like landscape for portrait mode so that ur app looks portrait in landscape mode.

sandrstar
  • 12,503
  • 8
  • 58
  • 65
Ruban
  • 1,514
  • 2
  • 14
  • 21
  • Haha . . this works only when inside the app . . . I want this to work on a widget button press so that it'll be visible always even on the homepage . . . nice trick btw :P – Prince Champappilly Aug 21 '13 at 07:02
  • You'd need to modify the Android OS to some extent, but since Android is open source, that's not a problem. The problem is getting it installed on phones - if you've noticed, the only companies that have custom UIs are also phone manufacturers, so they can just ship their phones with it installed. – Ruban Aug 21 '13 at 09:27
  • I am manufacturing the tablet and I have already got my android source up and running on my tablet . . I just want to kno which part of the source I need to edit to add my signal bar to the notification part. – Prince Champappilly Aug 21 '13 at 13:07
  • That is why I tagged android-source , only people who have experience with editing android source can help me . . . ty for ur effort though :) – Prince Champappilly Aug 21 '13 at 13:08
-2
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);
        }
dipali
  • 10,966
  • 5
  • 25
  • 51
  • This is not what he is looking for, he wants the icon in notification bar to be displayed on right side. – Sunil Mishra Aug 21 '13 at 06:22
  • Notification notification = new Notification(icon, tickerText, when); please find this line in above code..this line is display icon of notification in statusbar. – dipali Aug 21 '13 at 06:24
  • this will create a default notification, check http://developer.android.com/reference/android/app/Notification.html – Sunil Mishra Aug 21 '13 at 06:30
  • dipali this is to create one on the left side as a simple notification . . . I know this . . . what we want is to get this on the right side along with the signal strength and battery icon – Prince Champappilly Aug 21 '13 at 07:00
  • it is built-in functionality to display notification. – dipali Aug 21 '13 at 07:04
  • yes yes everyone knows how to make notification . . . ty for ur effort tho . . . but im not looking for "how to display notification" – Prince Champappilly Aug 21 '13 at 08:42
-2

I found some related information regarding your question on this forum...

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

--Good day

Xan
  • 7
  • 2