Created
October 29, 2017 18:25
-
-
Save adrianomelo/f45c47d7cfeab604cfa2936fb8784f3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.statusbar" | |
android:versionCode="1" | |
android:versionName="1.0"> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> | |
<uses-sdk | |
android:minSdkVersion="16" | |
android:targetSdkVersion="22" /> | |
<application | |
android:name=".MainApplication" | |
android:allowBackup="true" | |
android:label="@string/app_name" | |
android:icon="@mipmap/ic_launcher" | |
android:theme="@style/AppTheme"> | |
<activity | |
android:name=".MainActivity" | |
android:launchMode="singleTask" | |
android:label="@string/app_name" | |
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" | |
android:windowSoftInputMode="adjustResize"> | |
<intent-filter> | |
<action android:name="android.intent.action.VIEW" /> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
<category android:name="android.intent.category.BROWSABLE" /> | |
<data android:scheme="testapp" android:host="testapp" /> | |
<data android:scheme="testapp" android:host="testapp2" /> | |
</intent-filter> | |
</activity> | |
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> | |
</application> | |
</manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View, Slider, StatusBar, Linking } from 'react-native'; | |
export default class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
url: '?' | |
} | |
this._handle = this._handleOpenURL.bind(this); | |
} | |
componentDidMount() { | |
Linking.addEventListener('url', this._handle); | |
} | |
componentWillUnmount() { | |
Linking.removeEventListener('url', this._handle); | |
} | |
_handleOpenURL(event) { | |
this.setState(() => ({url: event.url})) | |
} | |
_open(url) { | |
Linking.openURL(url).then(value => { | |
console.log('open', value) | |
}).catch(e => { | |
console.log('error', e) | |
}) | |
} | |
render() { | |
const {url} = this.state; | |
return ( | |
<View style={styles.container}> | |
<StatusBar | |
translucent={true} | |
barStyle='dark-content' | |
backgroundColor='transparent' /> | |
<Text | |
style={styles.text} | |
onPress={this._open.bind(this, 'testapp://testapp')}> | |
URL1! | |
</Text> | |
<Text | |
style={styles.text} | |
onPress={this._open.bind(this, 'testapp://testapp2')}> | |
URL2! | |
</Text> | |
<Text style={styles.text}>{url}</Text> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
flexDirection: 'column', | |
justifyContent: 'center' | |
}, | |
text: { | |
textAlign: 'center', | |
lineHeight: 30 | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
<!-- Customize your theme here. --> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment