How to create a Notification \ status bar icon on the right side?
Asked Answered
C

5

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.

Cicerone answered 21/8, 2013 at 6:10 Comment(5)
Are you talking about how to make an Android TABLET style status bar?Dentelle
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.Cicerone
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 ??Cicerone
Hey if you've figure this out please share a snippetAcademicism
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.Gardener
D
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.

Dentelle answered 10/12, 2013 at 9:39 Comment(6)
Finally a Good Lead . . tnx mate :)Cicerone
@PrinceChampappilly any progress with this answer? vallathum nadakkumo?Rufus
@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.Cicerone
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?Inaugurate
@Inaugurate Hi. Do you now know the answer to that question?Journalize
@DADi590 it is a long time ago. Unfortunately, I could not check or remember.Inaugurate
U
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.

Usherette answered 23/9, 2014 at 16:19 Comment(0)
R
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.

Roca answered 21/8, 2013 at 6:34 Comment(4)
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 :PCicerone
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.Roca
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.Cicerone
That is why I tagged android-source , only people who have experience with editing android source can help me . . . ty for ur effort though :)Cicerone
S
-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);
        }
Seif answered 21/8, 2013 at 6:16 Comment(6)
This is not what he is looking for, he wants the icon in notification bar to be displayed on right side.Staunch
Notification notification = new Notification(icon, tickerText, when); please find this line in above code..this line is display icon of notification in statusbar.Seif
this will create a default notification, check developer.android.com/reference/android/app/Notification.htmlStaunch
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 iconCicerone
it is built-in functionality to display notification.Seif
yes yes everyone knows how to make notification . . . ty for ur effort tho . . . but im not looking for "how to display notification"Cicerone
N
-2

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

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

--Good day

Negron answered 21/8, 2013 at 6:17 Comment(1)
I'm looking for the android notification bar . . not that one :PCicerone

© 2022 - 2024 — McMap. All rights reserved.