Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Prevent Android notification.confirm from closing on background tap
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  18 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cory  
View profile  
 More options Jan 17, 12:06 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 09:06:14 -0800 (PST)
Local: Thurs, Jan 17 2013 12:06 pm
Subject: Prevent Android notification.confirm from closing on background tap

Hello,
I just realized that the Android native notification.confirm dialog can be
closed by tapping the background.
Is there a way to prevent it?

Thanks!

Using phonegap 2.3.0 , android 4.0.4 Xoom Tablet.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon MacDonald  
View profile  
 More options Jan 17, 12:11 pm
From: Simon MacDonald <simon.macdon...@gmail.com>
Date: Thu, 17 Jan 2013 12:11:47 -0500
Local: Thurs, Jan 17 2013 12:11 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

You'd have to modify the Notification.java file in and change

setCancelable(true);

to

setCancelable(false);

Simon Mac Donald
http://hi.im/simonmacdonald


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 17, 12:44 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 09:44:10 -0800 (PST)
Local: Thurs, Jan 17 2013 12:44 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Ahh i remember that when I coded in native.
Where is this file by the way?
All I could find is the android jar file and the notification.class file.

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 17, 12:48 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 09:48:03 -0800 (PST)
Local: Thurs, Jan 17 2013 12:48 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Ok I think we are talking about the same file , but I dont see
setCancelable(true) anywhere in that file.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 17, 1:11 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 10:11:46 -0800 (PST)
Local: Thurs, Jan 17 2013 1:11 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

I think you meant dialog class right?

Also , i set mCancelable to false by default and also on the show method ,
i used the method "setCloseOnTouchOutside" on  mWindow  ,setting it to be
false on the show method.

Hmmm, ok its not working.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon MacDonald  
View profile  
 More options Jan 17, 1:30 pm
From: Simon MacDonald <simon.macdon...@gmail.com>
Date: Thu, 17 Jan 2013 13:30:05 -0500
Local: Thurs, Jan 17 2013 1:30 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=blob;...

Simon Mac Donald
http://hi.im/simonmacdonald


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 17, 2:10 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 11:10:42 -0800 (PST)
Local: Thurs, Jan 17 2013 2:10 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Oh in phonegap itself...
Ok, so how do I do this?
Sorry , I havent done such a thing before.
Do I download the source code from github,  edit the file and then export
the jar file?
Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Airblader  
View profile  
 More options Jan 17, 2:26 pm
From: Airblader <ingo.bu...@googlemail.com>
Date: Thu, 17 Jan 2013 11:26:59 -0800 (PST)
Local: Thurs, Jan 17 2013 2:26 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Instead of changing the way confirm behaves my suggestion would be writing
a plugin instead. That way you can update to future PG releases without the
danger (and annoyance) of updating it everytime.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 17, 2:46 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 11:46:54 -0800 (PST)
Local: Thurs, Jan 17 2013 2:46 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Well , I wish I knew how to do either. Found a plugin tutorial , will
probably be able to do it , but it will probably take some time too.
I just want to know how to update/edit the notification.java file.
It'll be really helpful.
Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Airblader  
View profile  
 More options Jan 17, 2:53 pm
From: Airblader <ingo.bu...@googlemail.com>
Date: Thu, 17 Jan 2013 11:53:18 -0800 (PST)
Local: Thurs, Jan 17 2013 2:53 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Writing a plugin really isn't that hard, especially since you can basically
copy the Notification plugin, give it a different name, throw out
everything you don't need and add setCancelable(false). I wrote this just
in a text editor, so I didn't test it and there are gonna be unused
imports, but other than that it should hopefully work:
http://pastebin.com/8G5KAnLe
Now you just gotta write the JS interface for the plugin, register it in
your config.xml and you should be good to go.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 17, 3:24 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 12:24:51 -0800 (PST)
Local: Thurs, Jan 17 2013 3:24 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Well thanks for the help!

But all i got for the JS interface was this.
Im not sure how to continue. Really confused on the parameters for "
confirm: function (success, fail, resultType) "
I just want to call it like how you call it in phonegap, but in this case
it will be ConfirmDialogPlugin.confirm(.....) of course.

var ConfirmDialogPlugin = {
    confirm: function (success, fail, resultType) {
      return cordova.exec( success, fail,
                           "com.example.ConfirmDialogPlugin",
                           "confirm", [resultType]);
    }

};

Thanks

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Airblader  
View profile  
 More options Jan 17, 3:47 pm
From: Airblader <ingo.bu...@googlemail.com>
Date: Thu, 17 Jan 2013 12:47:18 -0800 (PST)
Local: Thurs, Jan 17 2013 3:47 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Again, untested, but try this: http://pastebin.com/jeUZXtQs
You should be able to call it with window.modalConfirm.confirm(...) then.
The signature is the same as the Notification plugin's confirm.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon MacDonald  
View profile  
 More options Jan 17, 4:26 pm
From: Simon MacDonald <simon.macdon...@gmail.com>
Date: Thu, 17 Jan 2013 16:26:51 -0500
Local: Thurs, Jan 17 2013 4:26 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

The easiest thing for you to do would be to extend the Notification class
and over-ride the confirm method. The new method would be identical to the
one that is already there except the one line change. Then in plugins.xml
where it specifies the class that provides the Notification interface you
would change it to be your class.

At least that is how I would do it. Mind you I wouldn't do it as the
confirm dialog is setup that way in the Android OS and we are just
following suit.

Simon Mac Donald
http://hi.im/simonmacdonald

On Thu, Jan 17, 2013 at 3:47 PM, Airblader <ingo.bu...@googlemail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 17, 4:48 pm
From: Cory <coryta...@gmail.com>
Date: Thu, 17 Jan 2013 13:48:20 -0800 (PST)
Local: Thurs, Jan 17 2013 4:48 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Man, its not working. Got define is not defined in the logs.
I'm giving up.

Cant find a standard way to interface javascript with native code. I always
thought there was , but cant seem to find it.
Thanks for the help anyways. Cant learn how to setup the plugins from
javascript side.

Could you write down the steps to override the notification class?
In my mind it would be like:
1) Create a class in the package in src in the project (e.g com.projectname)
2) Copy the Notification code and edit
3) Change Notification plugin values in config.xml


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon MacDonald  
View profile  
 More options Jan 17, 9:56 pm
From: Simon MacDonald <simon.macdon...@gmail.com>
Date: Thu, 17 Jan 2013 21:56:57 -0500
Local: Thurs, Jan 17 2013 9:56 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

Sorry very busy, don't have time to write this code. Also, I don't agree
with the change to standard Android behaviour. Read up on Plugins:

http://docs.phonegap.com/en/2.3.0/guide_plugin-development_index.md.h...
http://docs.phonegap.com/en/2.3.0/guide_plugin-development_android_in...

Simon Mac Donald
http://hi.im/simonmacdonald


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Airblader  
View profile  
 More options Jan 18, 2:21 am
From: Airblader <ingo.bu...@googlemail.com>
Date: Thu, 17 Jan 2013 23:21:09 -0800 (PST)
Local: Fri, Jan 18 2013 2:21 am
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

I agree, Simon's idea is better (if in fact you do want every confirm to be
modal). You got the steps pretty much right:

1) Copy the Notification.java plugin into your project
2) Modify the setCancelable call
3) Adjust the class to be in the correct package (your IDE should warn you
and do that for you anyway)
4) Go to res/xml/config.xml and change the Notification plugin to refer to
the class you just created

That should be pretty much it.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cory  
View profile  
 More options Jan 18, 10:20 am
From: Cory <coryta...@gmail.com>
Date: Fri, 18 Jan 2013 07:20:39 -0800 (PST)
Local: Fri, Jan 18 2013 10:20 am
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

@Simon Ahh yeah i saw that finally. I thought it would be atleast
documented somewhere else.
I understand , I dont want to ask for code too , just tutorials or examples.

@Airblader
Ok thanks!

Anyway, I got it to work.
Well , to me since the confirms have atleast two choices , the code should
expect a selection to determine which course of action should be taken.
Luckily for me , the default action does nothing so older versions of my
app wont have major implications. But I just want to make sure the user
reads the message and presses a button.

Its sort of like javascript confirms and alerts where you have to click the
ok button before moving on.

Once again , thanks for the great help!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Airblader  
View profile  
 More options Jan 18, 12:17 pm
From: Airblader <ingo.bu...@googlemail.com>
Date: Fri, 18 Jan 2013 09:17:07 -0800 (PST)
Local: Fri, Jan 18 2013 12:17 pm
Subject: Re: [PhoneGap] Prevent Android notification.confirm from closing on background tap

I'm completely with you, confirm dialogs feel like a modal thing to me too
– but I also agree with Simon that the native default behavior is what PG
should go with. I had to do the same thing in my app, but I didn't just
change the confirm dialog, I actually made a (modal) list dialog out of it
to allow for more than three options.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »