no status bar in phone gap? - javascript

I have been trying to get the status bar to go away as i want to put a fullscreen game in.
i'm using phonegap for the iphone
thanks in advance.

For iPhone simply add
<key>UIStatusBarHidden</key>
<true />
in your [appname]-info.plist file
For completeness if you also wish to roll out for android this solution worked well
In the file where you change activity to droidgap
public class app extends DroidGap
Add the following import
import android.view.WindowManager;
And then append the following within the class method
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.loadUrl("file:///android_asset/www/index.html");
}
Hope this helps
regards

If you want to the app to load with the status bar initially hidden:
[appname]-info.plist file
Find "Status bar is initially hidden"
Add new row if it isn't already there
Select 'YES' for the value
"Status bar is initially hidden" is the key that is available at least in xcode 4.2 beta 5.

You can try:
1) call this:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]
2) or this from your view controller.
[self setWantsFullScreenLayout:YES];
3) You can do it from the Interface Builder. Here's a video about it:
http://www.youtube.com/watch?v=aPAChohC-4Q
4) Someone else asked the same thing and got some related answers:
Fullscreen UIView with Status bar and Navigation Bar overlay on the top

For iOS7, you'll need to set the following setting in your [appname]-info.plist:
'View controller-based status bar appearance' to NO (Boolean)

Related

Android Studio WebView click on a loaded html page's element

I am loading a website in my app that contains an element I want to programmatically click (automate the click) as when this is clicked is time sensitive. I have the timing part down but need to trigger this element via an on screen click. I have read that performClick() "should" work but I have no way to verify if its actually clicking in the webview or not. The element in the html I need to trigger with a "touch" is called 'overlay'. Could someone provide me with a template that could do this?
You can use the below snippet to trigger at touch.
Video_Player.my_runnable = new Runnable()
{
#Override
public void run()
{
view.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis() + 50,MotionEvent.ACTION_DOWN,300,300,0));
view.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis() + 50,MotionEvent.ACTION_UP,300,300,0));
}
};

UrbanAirship - HTML Button - set tag to pass to code

What I am wanting to do is simple. I am using UrbanAirship to show a modal view ("In-app Automation"), which is HTML. I have a button in my HTML. The message/view is showing fine when the event is fired. Right now I have in the HTML for the button:
<button class="light" type="button" onclick="UAirship.close()">OK</button>
When the button is tapped, the call to UAirship.close() works fine and closes the message. I setup a listener in my Android code, such as follows:
UAirship.shared()
.getInAppMessagingManager()
.addListener(new InAppMessageListener() {
#Override
public void onMessageDisplayed(#NonNull String scheduleId, #NonNull InAppMessage message) {
// gets here fine
}
#Override
public void onMessageFinished(#NonNull String scheduleId, #NonNull InAppMessage message, #NonNull ResolutionInfo resolutionInfo) {
// gets here fine as well
}
});
It gets into those methods without any issues when the message/view shows and dismisses. However, I want to be able to detect one particular button was tapped vs. others I have in the HTML. Is there a way to go about this easily, so that some custom tag or something can be passed in the "ResolutionInfo" object or "InAppMessage"?
My hopes were that there would be something like "UAirship.close('tag')", where that tag would be passed back. Or even a custom HTML tag I can put on the button that would be recognized in the code. Really just any way of going about it is fine, I just can't seem to find in the documentation how to properly do this with HTML.
I'm looking at the documentation here. I see the UAirship.runAction() method, but it's not really clear to me what a simple implementation would be for this (also, the "CustomAction" class referenced in the action registering doesn't even exist in the library it seems..).
I basically just need to call one line of code in my Activity when the Airship message closes after that button is tapped.
Thoughts?
I've found that this solution works, although there may be a better one out there.
In the HTML, for the button, call the close() and then a runAction() call:
onclick="UAirship.close(); UAirship.runAction('my_action', null, null)"
Then in the code, in my onCreate() in my Activity, I have this:
final String actionName = "my_action";
Action customAction = new Action() {
#NonNull
#Override
public ActionResult perform(#NonNull ActionArguments actionArguments) {
String buttonActionName = actionArguments.getMetadata().getString(ActionArguments.REGISTRY_ACTION_NAME_METADATA);
if (buttonActionName.equals(actionName)) {
// DO WHAT IS NEEDED HERE
}
return ActionResult.newEmptyResult();
}
};
​
UAirship.shared()
.getActionRegistry()
.registerAction(customAction, actionName);

Android webView disable Wikipedia search bar

I'm building an app which using webView and loading Wikipedia's web pages. I would like to disable this part:
I don't know what is the best way to do this... I have thought of auto scrolling down, but then the user is able to scroll up.
Auto scrolling down is also doesn't accurate and may hide some of the value's information.
Thanks.
By looking into Wikipedia's source code you can see that the search bar is located inside a div container with the class name "header-container header-chrome". You are able to remove it from the view using JavaScripct code and the HTML DOM getElementsByClassName() Method.
The following code might help you with removing the search bar from the HTML page and display the rest.
WebView myWebViewDisply = (WebView) findViewById(R.id.WebViewDisply);
myWebViewDisply.getSettings().setJavaScriptEnabled(true);
myWebViewDisply.setWebViewClient(new WebViewClient() {
#Override
public void onPageFinished(WebView view, String url) {
myWebViewDisply.loadUrl("javascript:(function() { " +
"document.getElementsByClassName
('header-container header-chrome')[0].style.display='none';"
+"})()");
}
});
myWebViewDisply.loadUrl(youUrl);

Cordova plugin to send data to javascript code from native android activity

I am doing a Hybrid Android app. My landing page will be a custom android activity which will have login and signup buttons. Once I click any of these buttons, another activity which is a subclass of CordovaActivity should be launched and load the corresponding html view in CordovaWebView of the activity. However I am facing issues in sending which html view (login/signup) should be loaded in the CordovaWebView upon the button click. That is how should i send some parameters from native android activity to javascript to identify login/signup ?
I know this question is a bit old. But why not perform the condition check in your native activity, and save the required condition in your SQLite DB. As in :
if (buttonAIsClicked) {
saveConditionsForButtonA();
} else if (buttonBIsClicked) {
saveConditionsForButtonB();
}
Then upon load of your CordovaActivity, (JavaScript Code = ng-controller) check your DB for the value of the clicked button based on the saved value
var buttonClicked = getWhichButtonWasClicked(); //from DB
and act accordingly.
if (buttonClicked == buttonA) {
$state.go(paramNameA);
} else if (buttonClicked == buttonB) {
$state.go(paramNameB);
}
I know this is a hack. But that is how I did it, and it worked.
I hope this will be of help.

Disable vibrate on Android when button held down

I have a webpage that repeats a button action when held down. It works great, except the phone then vibrates. Is there a way to disable vibrating?
This solution wouldn't work for anyone that needs some form of haptic feedback. However, I do not, and here is the magic line that fixed it:
webView.setHapticFeedbackEnabled(false);
To disable vibrating on longpress use,
#Override
public void onLongPress(MotionEvent e) {
AudioManager audio=(AudioManager)getSystemService(AUDIO_SERVICE);
audio.setRingerMode(audio.RINGER_MODE_SILENT);
}
Then set it back if required.

Categories

Resources