[android-developers] Switching IME/Keyboard once only

2013-02-14 Thread brandall
My application has an inbuilt IME which the user has set to their default. 
In certain situations within my app (I won't bore you with which), I need 
to automatically switch to an alternative keyboard, but just for that one 
view - as soon as the user clicks on another view (or exits the 
application), it will return to my default IME.

I've tried so many options to accomplish this, but enabling another IME in 
any way is making it the users default IME from then on.

I have the imeToken, so switching to another IME is not a problem, but 
making this temporary is proving impossible Displaying the input method 
picker is a cumbersome method.

Is this by design and am I therefore drawing a blank?


-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Switching IME/Keyboard once only

2013-02-14 Thread brandall
Thanks for your reply - You are able to switch the 
keyboard programmatically if you are the current IME token holder. My 
struggle is to request this change temporarily. 

On Thursday, February 14, 2013 5:45:35 PM UTC, Brill Pappin wrote:

 Unless things have changed recently, you can't programatically change the 
 input method because its too great a security risk.

 e.g. I could replace your keyboard with one that looked exactly the same 
 but captured everything you typed and sent it to my mob friends. In a day I 
 could have all your passwords, credit card numbers, security codes, love 
 letters, etc.

 By forcing you to ask the user to change it, it gives the user the 
 opportunity to decide if they trust the alternate input method.
 Of course, I'm not as up to speed on the most recent android versions, so 
 if things have changed, someone will point it out I'm sure.



 On Thursday, 14 February 2013 08:44:54 UTC-5, brandall wrote:

 My application has an inbuilt IME which the user has set to their 
 default. In certain situations within my app (I won't bore you with which), 
 I need to automatically switch to an alternative keyboard, but just for 
 that one view - as soon as the user clicks on another view (or exits the 
 application), it will return to my default IME.

 I've tried so many options to accomplish this, but enabling another IME 
 in any way is making it the users default IME from then on.

 I have the imeToken, so switching to another IME is not a problem, but 
 making this temporary is proving impossible Displaying the input method 
 picker is a cumbersome method.

 Is this by design and am I therefore drawing a blank?




-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] onutterancecompletedlistener UtteranceProgressListener not fired

2012-11-30 Thread brandall
This question is a long shot, as it's a peculiar problem

I have a foreground service which controls my application's text to speech 
and recognition functionality. My implementation works correctly for 
thousands of users, but a handful a Galaxy SIII users are reporting a 
problem whereby onutterancecompletedlistener or UtteranceProgressListener 
is not called, which is the trigger for the recognition to start, making 
the application useless.

The application works fine from a launcher shortcut/shake/widget, until the 
user opens another application!? As soon as they open another application 
and attempt to start my app again, the listener is not called. The service 
needs to be restarted in order for it to function again.

I have tried absolutely everything and read every post out there, with 
various suggestions of where to put the listener (onInit). I've tried 
static implementations, randomly generating the utteranceID, applying 
individual listeners to each possible call to the speech engine (checking 
all possibilities of null objects) but nothing fixes it - It speaks 
successfully and then nothing

So, without me posting my thousands of lines of code, could anyone suggest 
an Android fundamental reason why the listener would fail to be called 
after an application is opened!?! I'm totally baffled as to how this could 
even be a possibility or interfering with my app?

Suggestions welcome! Thank you.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: java.lang.IllegalArgumentException: contentIntent required

2012-07-03 Thread brandall
It seems there is no answer here or on Stackoverflow for this behaviour, so 
I have to assume it's a notification from a service bug for a small number 
of Android devices.  Where do I report this as a bug? 


On Saturday, June 30, 2012 9:19:18 PM UTC+1, brandall wrote:

 The full error also contains:

 android.app.RemoteServiceException: Bad notification for startForeground:

 I've read other similar posts 
 herehttp://stackoverflow.com/questions/3112008/android-java-lang-illegalargumentexception-contentintent-required-error-cause,
  
 tried their suggestions and read their links, but a small number of users 
 are still reporting this error.

 *Overview*

 An activity is started by an external application. This activity starts a 
 custom speech recognition service. It *does not* use startForeground:

 this.startService(intent);

 The activity then calls finish();

 The service starts the custom speech recognition class and passes context 
 to it in a constructor. On 'beginning of speech detected' I display the 
 following notification:

 String notTitle = Hello;
 String notificationText = hello there;

 notificationManager = 
 (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
 myNotification = new Notification(
 android.R.drawable.ic_btn_speak_now, notTitle,
 System.currentTimeMillis());
 myNotification.flags |= Notification.FLAG_AUTO_CANCEL;

 Intent intent = new Intent();
 intent.setAction(com.android.settings.TTS_SETTINGS);
 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, 
 intent, 0);
 myNotification.contentIntent = pendingIntent;

 myNotification.setLatestEventInfo(mContext, notTitle,
 notificationText, pendingIntent);

 notificationManager.notify(MY_NOTIFICATION_ID, myNotification);

 The notification has no requirement to do anything 'onClick' as it's 
 cancelled as soon as the user stops talking. I was originally passing a 'null 
 intent', however, after reading many posts, I added in the random 
 intent/pendingIntent of displaying TTS Settings, just to rule this out as the 
 problem.

 99% of my users don't have an issue with either the above code or passing a 
 null intent. I need to solve this for the 1% though, as it's a very important 
 part of my application.

 Any suggestions would be very much appreciated.



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: java.lang.IllegalArgumentException: contentIntent required

2012-07-03 Thread brandall


 There should be an error message appearing to the right of the Bad 
 notification for startForeground: portion of your message, based upon 
 the source code that I am reading. Are you sure there is nothing 
 there? Posting the entire stack trace is considered a fairly 
 conventional step when you seek assistance for issues like this. 


Thanks for your response Mark. The rest of the stack trace is:

java.lang.IllegalArgumentException: contentIntent required: 
pkg=com.brandall.nutter id=1079820303 
notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x60)

There's nothing else relevant in the output. 


 Also, have you tried switching to Notification.Builder or 
 NotificationCompat.Builder? 


I'm targeting 2.2, so couldn't use Notification.Builder. Thank you for 
pointing out the Compat builder, I can't believe I hadn't come across that 
anywhere in my many hours of trying to resolve this...I'll try it. 


 com.android.settings.TTS_SETTINGS is not part of the Android SDK, 
 near as I can tell, so you should not be using it in the first place. 
 [SNIP] 

 It is fairly safe to 
 assume that not all devices will offer an activity for this 
 undocumented and unsupported action. 

 Then, and only then, file an issue on http://b.android.com. 


Point taken thanks - I should have clarified that I'd tried a null activity 
as well as an activity to open my application and eventually the TTS 
Settings. In all cases successful for 99% of my users. The remaining 1%, no 
joy...

Thanks for the link. 


 -- 
 Mark Murphy (a Commons Guy) 
 http://commonsware.com | http://github.com/commonsguy 
 http://commonsware.com/blog | http://twitter.com/commonsguy 

 _The Busy Coder's Guide to Android Development_ Version 3.7 Available! 


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: java.lang.IllegalArgumentException: contentIntent required

2012-07-03 Thread brandall



  java.lang.IllegalArgumentException: contentIntent required: 
  pkg=com.brandall.nutter id=1079820303 
  
 notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x60) 
  
  There's nothing else relevant in the output. 

 Is that in your null Intent case? The message makes more sense for 
 that than with the TTS_SETTINGS scenario. 


That is returned in all cases...null or activity. 


 It looks like contentIntent used to be required, but no longer is, as 
 of October 2010 (in terms of source code updates). Do you see a 
 pattern in OS versions in the devices that are hitting this? 

 I would recommend using an Intent that points to one of your 
 activities -- that avoids the TTS_SETTINGS problem and avoids the null 
 contentIntent. 


It's definitely replicated when using the main activity to launch the 
application. The stack did also contain:

W/19:27:15.560 ActivityManager(  220)
at 
com.android.server.NotificationManagerService.enqueueNotificationInternal(NotificationManagerService.java:888)
W/19:27:15.560 ActivityManager(  220)
Error showing notification for service

I haven't narrowed down which OS/Devices are having the problems - I will 
do though. A dev on StackOverflow commented on the linked post that he only 
found this issue on the Kindle Fire. I have LG devices reporting this 
though..

Can't help thinking that there's a glitch in the matrix on some devices 
where startforeground is 'expected' when firing a notification from a 
service... 

Thanks again for your replies. I'll continue to investigate.


 -- 
 Mark Murphy (a Commons Guy) 
 http://commonsware.com | http://github.com/commonsguy 
 http://commonsware.com/blog | http://twitter.com/commonsguy 

 _The Busy Coder's Guide to Android Development_ Version 3.7 Available! 


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: java.lang.IllegalArgumentException: contentIntent required

2012-07-03 Thread brandall



 Actually, I think that part of the message may be a fluke. There 
 appear to be two cases which call the postNotification() where that 
 exception is raised, and only one of those is for a startForeground() 
 scenario, if I am reading the source properly. 


To clarify, I don't call startForeground() in any of the cases. The purpose 
of the notification is purely visual and not to make the service 
foreground. Perhaps you were referring to the Activity that would be 
started though?? 

  


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: java.lang.IllegalArgumentException: contentIntent required

2012-07-03 Thread brandall


 No, I was referring to the error message. While it *says* Bad 
 notification for startForeground, it appears that this error might be 
 raised even if *nobody* called startForeground(). Hence, I am telling 
 you to not over-emphasize the Bad notification for startForeground 
 portion of the error, as it may be a red herring, fluke, or something 
 else fishy. 


I'm with you now. 


 IMHO, the real question is: where is your contentIntent going? 
 Somehow, Android is winding up with a Notification object that has a 
 null contentIntent, and that appears to be unsupported, at least on 
 Android 1.x/2.x. In the cases where you are explicitly supplying a 
 contentIntent, it should no longer be null. Are you doing anything to 
 the Notification object after you call notify()? 

 No, nothing... The notification says I'm listening and then is cancelled 
a few moments later 'on end of speech input'  from the service. First time 
I got the error using null contentIntent, I thought, okay, I'll just add in 
the content to suppress the error, but my headaches started when it appears 
to make no difference either-way or regardless of the actual contentIntent 
supplied...

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: java.lang.IllegalArgumentException: contentIntent required

2012-07-03 Thread brandall



 Is it possible that you are canceling it before it actually gets 
 displayed? IOW, how short might a few moments be? 

 I'm just brainstorming possible things that you are doing differently 
 than the norm. 


The notification is there for at least as long as I set the 'pause before 
assume speech has ended' parameter to. The endOfSpeech can't be called 
until after that event (where the notification is cancelled), so we can 
rule that one out. I'll push out the NotificationCompat.Builder update 
later, but even if (hopefully) it solves the issue, perhaps I should still 
do the honourable thing and raise it as a possible bug? Or in your 
experience, are depreciated method bugs pushed to the bottom of a very 
large pile and therefore pointless...? 

I appreciate your help. 

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: java.lang.IllegalArgumentException: contentIntent required

2012-07-03 Thread brandall


 Well, I don't see any deprecated methods in what you are doing. 
 However, bugs that cannot be reproduced tend to be problematic in all 
 software development. 

 I'd assumed that the posted method had been depreciated in favour of 
NotificationBuilder. I see that it hasn't though. 

I'll get the list of device/OS combination where this occurs and go from 
there. 

Thanks again for your input

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en