cordova - Sending url to ionic android app via webintents from another app -
looking updated solution, running latest ionic 1.1.0 release uses cordova 5.x. trying able browse website in chrome , send url ionic android app using web intent. app compiles , runs, when attempt use share feature chrome(or other app) , choose app share to, app crashes.
i first attempted use plugin:
ionic plugin add https://github.com/initsogar/cordova-webintent
and removed plugin , tried more updated fork:
ionic plugin add https://github.com/fluentstream/cordova-webintent
in app.js file putting following code:
.run(function($ionicplatform, $rootscope, $ionichistory, $state) { $ionicplatform.ready(function() { window.plugins.webintent.getextra(window.plugins.webintent.extra_text, function(url) { incomingurl = url; //alert(incomingurl); console.log(incomingurl); }, function() { incomingurl = false; //alert("no url"); console.log("no url"); }); }); })
i tried:
.run(function($ionicplatform, $rootscope, $ionichistory, $state) { $ionicplatform.ready(function() { window.plugins.webintent.geturi(function(url) { if(url !== "") { alert(url);//url url intent launched } }); }); })
in file config.xml put:
<plugin name="webintent" value="com.borismus.webintent.webintent"/>
in androidmanifest.xml manually put in:
<activity android:name="shareactivity"> <intent-filter> <action android:name="android.intent.action.send" /> <category android:name="android.intent.category.default" /> <data android:mimetype="text/plain" /> </intent-filter> </activity>
the app runs, when go chrome , click share button, , choose app, app shuts down following android message appears:
unfortunately, myappname has stopped.
can suggest solution getting share intent work app...or forgetting , doing wrong.
thank you!
found out problem due how set androidmanifest.xml file.
i using activity tag, when should have been including intent in 1 activity.
for instance had:
<activity android:configchanges="orientation|keyboardhidden|keyboard|screensize|locale" android:label="@string/activity_name" android:launchmode="singletop" android:name="mainactivity" android:theme="@android:style/theme.black.notitlebar" android:windowsoftinputmode="adjustresize"> <intent-filter android:label="@string/launcher_name"> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="shareactivity"> <intent-filter> <action android:name="android.intent.action.send" /> <category android:name="android.intent.category.default" /> <data android:mimetype="text/plain" /> </intent-filter> </activity>
when should have had:
<activity android:configchanges="orientation|keyboardhidden|keyboard|screensize|locale" android:label="@string/activity_name" android:launchmode="singletop" android:name="mainactivity" android:theme="@android:style/theme.black.notitlebar" android:windowsoftinputmode="adjustresize"> <intent-filter android:label="@string/launcher_name"> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.send" /> <category android:name="android.intent.category.default" /> <data android:mimetype="text/plain" /> </intent-filter> </activity>
Comments
Post a Comment