我正在使用webintent插件进行android扩展。 当我打开浏览器并点击分享时,我的分机就会显示出来。
我的扩展功能正常显示。
现在,我希望当我点击我的扩展程序时,我想列出一些类别名称。
知道怎么做吗?
这是我的AndroidManifest文件代码: -
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.myappDevelopment1" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<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" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
这是mu app.js代码: -
angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'ngStorage', 'toaster','angular.filter','angular-loading-bar','ngTagsInput'])
.run(function($ionicPlatform, userInfo) {
$ionicPlatform.ready(function() {
if (window.plugins && window.plugins.webintent) {
window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT, function (url) {
userInfo.getCategory().then(function(result) {
var html = [];
result.forEach(function(category) {
html.push(category.category_name);
});
document.querySelector("#categoryList").innerHTML = html;
},function(err){
alert(err);
});
}, function() { //Fail
alert ("error");
});
}
});
})
这是我的index.html文件: -
<!DOCTYPE html>
<html>
<head>
</head>
<body ng-app="starter">
<ion-nav-view animation="slide-left-right" class="slide-left-right">
</ion-nav-view>
<toaster-container toaster-options="{'time-out': 3000}"></toaster-container>
<div id="categoryList"></div>
</body>
</html>
答案 0 :(得分:0)
你可以试试这个
if (window.plugins && window.plugins.webintent) {
window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT, function (url) {
$ionicPopover.fromTemplateUrl('./templates/categorylist.html', {
scope: $rootScope,
}).then(function(popover) {
$rootScope.popover = popover;
//get result by calling factory etc
$rootScope.categories = result;
$rootScope.popover.show();
});
}, function() { //Fail
alert ("error");
});
}