Implement simple URI handler activity
This commit is contained in:
parent
06e5a94225
commit
8a532073ff
2 changed files with 59 additions and 11 deletions
|
@ -84,17 +84,10 @@
|
|||
android:minHeight="300dp"
|
||||
android:windowSoftInputMode="stateHidden"></activity>
|
||||
<activity
|
||||
android:name=".ui.StartConversationActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:name=".ui.UriHandlerActivity"
|
||||
android:label="@string/title_activity_start_conversation"
|
||||
android:theme="@android:style/Theme.NoDisplay"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SENDTO" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="imto" />
|
||||
<data android:host="jabber" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
|
@ -104,9 +97,11 @@
|
|||
<data android:scheme="xmpp" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
<action android:name="android.intent.action.SENDTO" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="xmpp" />
|
||||
|
||||
<data android:scheme="imto" />
|
||||
<data android:host="jabber" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
@ -120,6 +115,21 @@
|
|||
<data android:pathPrefix="/j/" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.StartConversationActivity"
|
||||
android:label="@string/title_activity_start_conversation"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="imto" />
|
||||
<data android:host="jabber" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.WelcomeActivity"
|
||||
android:label="@string/app_name"
|
||||
|
|
38
src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
Normal file
38
src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package de.pixart.messenger.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
public class UriHandlerActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
handleIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
handleIntent(intent);
|
||||
}
|
||||
|
||||
private void handleIntent(Intent data) {
|
||||
if (data == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (data.getAction()) {
|
||||
case Intent.ACTION_VIEW:
|
||||
case Intent.ACTION_SENDTO:
|
||||
final Intent intent = new Intent(getApplicationContext(),
|
||||
StartConversationActivity.class);
|
||||
intent.setAction(data.getAction());
|
||||
intent.setData(data.getData());
|
||||
intent.setAction(data.getAction());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
Reference in a new issue