In my activity i have a web view and in manifest.xml i have declared intent filter like this
<activity
android:name=".ui.socialNetwork.MySocialNetworkActivity"
android:configChanges="orientation|screenSize"
android:process=":fb"
android:screenOrientation="portrait" >
</activity>
<activity-alias
android:targetActivity=".ui.socialNetwork.MySocialNetworkActivity"
android:name=".AliasMySocialNetworkActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity-alias>
This is not launcher activity. The intent filter used here is for copy paste toolbar on web view long press.This works fine. In addition to this i want to use Webview.setOnLongClickListener() for additional options, and i implemented like this.
webView = (WebView) findViewById(R.id.webview);
PackageManager pm = getApplicationContext().getPackageManager();
ComponentName compName =
new ComponentName(getPackageName(), getPackageName() + ".AliasMySocialNetworkActivity");
pm.setComponentEnabledSetting(
compName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
webView.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
WebView.HitTestResult hitResult = null;
hitResult = webView.getHitTestResult();
if (hitResult != null && hitResult.getExtra() != null) {
final String hitRes = hitResult.getExtra();
if (hitResult.getType() == WebView.HitTestResult.IMAGE_TYPE || hitResult.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
Intent ImageSaveIntent = new Intent(getApplicationContext(), SaveImage.class);
ImageSaveIntent.putExtra("putImage", hitRes);
startActivity(ImageSaveIntent);
}
if (hitResult.getType() != WebView.HitTestResult.IMAGE_TYPE || hitResult.getType() != WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
PackageManager pm = getApplicationContext().getPackageManager();
ComponentName compName =
new ComponentName(getPackageName(), getPackageName() + ".AliasMySocialNetworkActivity");
pm.setComponentEnabledSetting(
compName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
}
return true;
}
});
My Problem is that
If i use intent filter alone without webview.setOnLongClickListener(), i can copy paste the text in webview
If i use webview.setOnLongClickListener() alone, i can do my additional options and it is working fine.
If i implement both intent filter and webview.setOnLongClickListener(), i cannot copy paste the text from webview. webview.setOnLongClickListener() will work fine. Here i understood that both functionalities depends on longPress, But i want both to work together.
I searched Webview.HitResult options for TextType, but it is not having such option. https://developer.android.com/reference/android/webkit/WebView.HitTestResult.html
Please help me in solving this.