Office Hours — Today, March 28

Tuesday, March 26

Mar 28
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Carlos
has entered the room
Mark M.
hello, Carlos!
how can I help you today?
Carlos
Hi Mark!
Dmitri P.
has entered the room
Mark M.
hello, Dmitri!
Carlos
Based on your feedback I started implementing the AlarmManager intent through a ScheduledService (similar to your example).
I added notifications using the NotificationCompat library and I'm able to open activity with intent's data.
Dmitri P.
Hello Mark!
I have a question regarding the size of a canvas - see http://stackoverflow.com/questions/15680744/siz... .
Carlos
The problem that I'm facing is that if the user presses a button from the action bar, the activity gets dismissed instead of going to main activity
However, if I press the up navigation button from the loaded activity is does go to the main activity.
Ron B.
has entered the room
Carlos
Could this be something related to the flags for the intent?
This is my sendReminder method:
View paste (1 more line)
private void sendReminder(Task task){
        AlarmManager mgr=
                (AlarmManager)getSherlockActivity().getSystemService(Context.ALARM_SERVICE);

        Intent i = new Intent(getSherlockActivity(), ScheduledService.class);
        i.putExtra("taskName", task.getTitle());
        i.putExtra("taskId", task.getId());
        GregorianCalendar cal = new GregorianCalendar(task.getYear(), task.getMonth(),
                task.getDay(), task.getHour(), task.getMinutes());
        long reminder = cal.getTimeInMillis();
        i.putExtra("taskDueDate", reminder);

        PendingIntent pi=PendingIntent.getService(getSherlockActivity(), 0, i, PendingIntent.FLAG_ONE_SHOT);
        mgr.setRepeating(AlarmManager.RTC_WAKEUP, reminder, 0, pi);
    }
...
4:00 PM
Mark M.
that's an AlarmManager schedule, not an action bar
Peri H.
has entered the room
Peri H.
Hi Mark, I'm back!
Mark M.
Dmitri: I have done little in this area, but onSizeChanged() has worked where I needed it -- not sure why it would not be working for you
(Ron, Peri: hello! I will be with you shortly)
Carlos
So during normal app operation the action bar buttons operate properly. The problem is when the activity is loaded after pressing the notification icon.
Mark M.
Carlos: my guess is that you are getting twisted up with different tasks
Dmitri P.
Mark, are there any specialties related to fragments?
Mark M.
Dmitri: not in terms of the sizes of widgets
Dmitri P.
OK, thanks.
Mark M.
Carlos: can you show your code for the PendingIntent you are using with the Notification?
Dmitri P.
Good bye.
Carlos
Mark, sorry. I was sure if the issue is in the intent to AlarmManager, or with the intent received in the onHandleIntent of the IntentService
Dmitri P.
has left the room
4:05 PM
Carlos
This is my notification code:
View paste (36 more lines)
@Override
    protected void onHandleIntent(Intent intent) {
        String title = intent.getExtras().getString("taskName");

        //TODO: Implement notification for current reminder
        String notif_title = "Task due: " + title;
        String notif_extra_content = "Touch for more options.";

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.stat_notify_voicemail)
                .setTicker(notif_title)
                .setWhen(System.currentTimeMillis())
                .setAutoCancel(true)
                .setContentTitle(notif_title)
                .setContentText(notif_extra_content);
...
Mark M.
I have not worked with TaskStackBuilder, because the very concept makes me angry
Carlos
Hehehe. Might I know why?
Mark M.
I don't like lying to users
anyway, you might consider running a test with a more conventional PendingIntent and see how that works with your action bar items
let me take questions from the others, and I will be back with you shortly
Carlos
So the way you normally do it. How do you handle the notifications for both pre-11 and post-11 levels?
Mark M.
Ron: do you have a question
Ron B.
Hi Mark
I'm trying to dynamically update the text in a button (view.setText()). If the text is too large, Android simply cuts it off. I'm using wrap_content for the width. Is there any way to set the button or the text to automatically adjust it's size? I'm implementing I18N so I have no way of predicting how long the strings will be.
Mark M.
the button should automatically resize, within whatever other constraints are placed upon it
Ron B.
Do I need any constraints other than wrap_content?
Mark M.
I have no idea
it's your UI, not mind
er, mine
but if the size of its container is constrained, the button cannot grow bigger than its container, etc.
an alternative approach is to change the font size of the text, as the AutoScale TextView does: http://www.androidviews.net/2012/12/autoscale-t...
4:10 PM
Mark M.
presumably, you could create an AutoScale Button based on the same concept
4:10 PM
Mark M.
but you may just want to start with Hierarchy View to figure out why your button is not getting any bigger
Ron B.
I tried it with or without "weight", without weight it was too large for the small strings.
Mark M.
weight is used to address under-allocation or over-allocation of space in a LinearLayout
again, I recommend that you use Hierarchy View to get a better grip on what your LinearLayout is doing and therefore why your button is not getting as big as you think it should
let me take questions from the others, and I will be back with you shortly
Peri: do you have a question?
Peri H.
Hi
Yes, I discovered a new "feature" of android. When you use getAccounts() to get a list of accounts for contacts, it returns duplicates.
Not exactly duplicates as the types are different.
4:15 PM
Peri H.
Anyway, I'm trying to figure out which ones are really valid accounts for creating contacts.
4:15 PM
Peri H.
I dug into the source for the android contacts editor and it appears that they select based on which accounts are writable.
From there I've gotten lost in a myriad of huge coe.
code.
I should add that AccountManger.getAccounts() does not return more than the account name and type (nothing about writable, etc)
Mark M.
I am not sure what to tell you, other than you already know much more about this stuff than I do
in particular, you have not really asked a question
Peri H.
Should I be flattered or disappointed? Ha ha.
Mark M.
definitely disappointed
Peri H.
Well, it was meant to be a question: I'm not sure how to tell whether the account is writable and, thus, usable for creating contacts.
Mark M.
beats me
sorry
Peri H.
Are there any ways, besides bounty on stackoverflow, to get more attention from the appropriate android team?
Mark M.
steal a conference ticket to I|O
note: this may be illegal in some jurisdictions
Peri H.
It's kind of their fault - no documentation and the implication that getAccounts() gives you what you need. Clearly it doesn't.
Ok, and I can break into the android lunchroom and stand on a table, too. :)
4:20 PM
Mark M.
you're welcome to try the android-developers Google Group as well
let me swing back through the others, and I'll return to you in a bit
Carlos: do you have another question?
Peri H.
Ok, why not. Thanks.
Carlos
Yes Mark.
I guess since you dislike Notification Builder. How would I go about supporting notifications for both Gingerbread devices as well as API11 and above
Mark M.
I have no problems at all with Notification.Builder
Carlos
Is there a similar example in your book?
Mark M.
I have problems with TaskStackBuilder
Carlos
ooops
Peri H.
has left the room
Mark M.
Notification.Builder (or, more accurately, NotificationCompat.Builder) is used for all the Notification samples in the book
Carlos
so instead of TaskStackBuilder you just use a regular intent?
Mark M.
PendingIntent, yes
Carlos
yep, yep.
I read your blog post. If I understood correctly you are saying that when a user presses on a notification to view the items related to that notification, pressing the back button should move the user's UI to whatever previous state they were before pressing the notification icon. As opposed to Google's recommendation which is to go to the root activity of the app for which I press the notification icon. Did I understood correctly?
Mark M.
no
there is the BACK button, and there is the home affordance in the action bar
they are not the same
4:25 PM
Carlos
I understand that Mark. I guess the guidelines are a little confusing regarding back operation.
Mark M.
yes, to me too
I haven't read through this in ages
just now re-reading that blog post
it's possible that the blog post is somewhat out of date relative to the design guidelines
Carlos
If I clicked on a notification and it opens my app. I understand that "up navigation" should go to root activity and pressing an AB item should work as normally (i.e. AB item done should process item edits and return to home activity). But still a bit confused on what should back button do if user does not press an AB item or the up navigation.
Mark M.
that depends on who you ask
if you ask Google, it goes somewhere the user has never been, via TaskStackBuilder or equivalent settings in the manifest
if you ask me and many other developers, it goes to whatever screen the user had been on before
while I generally advocate sticking with Google's design guidelines, this is one area where I do not
however, my original point was: see if TaskStackBuilder is what is causing the interference with how your action bar items are working
Carlos
yep. What you say makes sense. But it looks like most apps are following design guidelines. Most non-Google apps I use go to another screen within that app with the notification instead of going to previous state.
Ok Mark. Sounds good. Thanks for your time.
Mark M.
Ron: do you have another question?
4:30 PM
Carlos
has left the room
Ron B.
I'm all set for now. Thanks.
Mark M.
OK, if you come up with another question, chime in
Ron B.
has left the room
4:55 PM
Mark M.
turned off guest access

Tuesday, March 26

 

Office Hours

People in this transcript

  • Carlos
  • Dmitri Pisarenko
  • Mark Murphy
  • Peri Hartman
  • Ron Bruckman