I need help detecting and dealing with the home button being pressed on a iPhone/iPod Touch running an AIR app. I tried
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
function handleKeys(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.HOME) {
//do something
}
}
without luck. Any ideas? Specifically, I want to prevent the app from closing when the home button is pressed.
import flash.events.Event;
addEventListener(Event.ACTIVATE, activateListener);
addEventListener(Event.DEACTIVATE, deactivateListener);
private function activateListener(e:Event):void{
//do something when awakened
}
private function deactivateListener(e:Event):void{
//do something when home button is pressed.
}
Related
I know how to enter fullscreen once it's already loaded in a window. This causes an ugly effect where, when I click its icon, briefly flashes a windowed window which immediately goes fullscreen. I hate that effect.
How do I make it actually start, right away, in fullscreen, without ever being in windowed mode even for a split second?
You just need to put fullscreen: true in your manifest: https://docs.nwjs.io/en/latest/References/Manifest%20Format/#fullscreen.
If you want more info go to https://www.w3schools.com/howto/howto_js_fullscreen.asp#:~:text=To%20open%20an%20element%20in%20fullscreen%2C%20we%20use,fullscreen%20mode%20%28a%20video%20in%20this%20example%29%3A%20%2A%2F
this would work if youre making an website
function openFullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) { /* Safari */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE11 */
elem.msRequestFullscreen();
}
}
/* Close fullscreen */
function closeFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) { /* Safari */
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) { /* IE11 */
document.msExitFullscreen();
}
}
I'm not a JS pro but I code in python and i think if you made a function like this one it would work idk though
function onstart(){
if (boolean == true):
// Fullscreen code
}
// Your code here
onstart()
I started to work on my first mobile game in Unity. For now, the game I am working is Pong.
The problem that I am having is that I want to create the pause and resume buttons but whenever I create and tap on them, nothing happens.
This is the created button:
This is my canvas:
This is the event system:
This is the code I use for my button. It works fine when I clic it but not when I tap it:
private void pause() {
Time.timeScale = 0f;
}
private void resume()
{
Time.timeScale = 1f;
}
public void pauseResume() {
if (!paused)
{
pause();
paused = true;
}
else {
if (paused)
{
resume();
paused = false;
}
}
}
I tried using Event triggers but it does not work so my theory is that the problem is not in the way I create the buttons or the way the resume pause method is coded. Something is blocking me of using the button in my device (Iphone 8).
How do I know when the application has been clicked? I'm using 'Share' from React Native. I want to know as soon as a user clicks an app icon (e.g. Instagram) and then launch my own function, not the share page in Instagram. How can I capture that the user has just clicked the app icon?
Right now if I click the app icon, it moves to the app's (e.g. Instagram's) share page, and when I dismiss it, then it tells me what my sharedAction was (which is too late!). I don't want to have to enter the share page at all.
I need to know when I've selected the Instagram app icon, so I can launch my own function.
import { Share } from 'react-native'
shareImage = async() => {
const result = await Share.share(
{
message: 'Hello',
url: "www.image...."
},
)
.then(res => console.log(res))
if (result.action === Share.sharedAction) {
if (result.activityType) {
// shared with activity type of result.activityType
} else {
// shared
}
} else if (result.action === Share.dismissedAction) {
// dismissed
}
}
In general you can get information from result.activityType. Unfortunately I don't know the activityType of Instagram, but you can try it out by checking the activityType. Below, I have an example where we want to detect if the Clipboard was used.
For example:
if (result.action === Share.sharedAction) {
console.log(result.activityType) // here you can see the activityType
if (result.activityType == "com.apple.UIKit.activity.CopyToPasteboard") {
// Copy to Clipboard was used
}
// first you have to check the activityType of instagram
if (result.activityType == "INSTAGRAM_ACITVITY_TYPE") {
// Instagram share extension was used
}
} else if (result.action === Share.dismissedAction) {
// dismissed
}
I am implementing searchbar in Ionic 2. When I run the app in iOS, in simulator or on a real device it doesn't work properly. When I click Cancel the keyboard closes at first and then reopens again. The searchbar, still has the cursor in it.
This what I have done.
.html
<ion-searchbar
placeholder = "Kerko"
(keyup.enter)="search(q.value)"
[showCancelButton]="true"
(ionCancel)="reset($event)"
></ion-searchbar>
.ts
constructor(private navCtrl:NavController,
public keyboard: Keyboard,
private platform: Platform) {
}
search(q: string) {
console.log(q);
this.navCtrl.push(SearchPage, {"query": q});
}
reset(event) {
this.keyboard.close();
}
Any idea how to solve this?
I want to create an app that has a button to lock, and another button to unlock.
Lock - This button will lock device. Only this app's screen will show nothing else will be accessible even after restart same screen will show up. Home button, gestures will get disabled similar to single app mode.
Unlock - This will unlock device and switch to normal behavior of device.
Here's what I tried:
#IBAction func lock(sender: UIButton)
{
UIAccessibilityRequestGuidedAccessSession(true) {
success in
println("\(success)") // success is false
}
}
#IBAction func unlock(sender: UIButton)
{
UIAccessibilityRequestGuidedAccessSession(false) {
success in
println("\(success)") // success is false
}
}
When I lock it and then press the home button, it goes home. Am I doing anything wrong? What can I do to fix it?
P.S. I'm new to swift coming from Objective-c