2015-08-28 18 views
30

Tôi thích Office Lens 's khả năng tự động cắt, tập trung, và sắp xếp một bức tranh ... chủ yếu để tiếp nhận và chi phí chế biếnTôi có thể tích hợp Microsoft Lens vào ứng dụng của mình không?

Tôi muốn có một dòng chảy ứng dụng mà đi như thế này:

  1. tài mở ứng dụng của tôi và nhấp chuột nhận bức ảnh
  2. Lens mở ra (ý định android, hoặc tương tự trong iOS)
  3. tài mất hình ảnh
  4. ảnh được trả lại cho ứng dụng của tôi để chế biến

Tôi gặp sự cố khi thực hiện luồng đó và thực hiện truyền dữ liệu (ảnh) giữa máy ảnh và ứng dụng của tôi liền mạch. Tôi có những lựa chọn nào?

+0

Loại ứng dụng nào bạn đang muốn xây dựng, đây có phải là tiện ích bổ sung cho văn phòng hay một số loại ứng dụng khác không? Bạn đã gắn thẻ câu hỏi với văn phòng-addins, nhưng tôi muốn kiểm tra lại –

Trả lời

2

Tôi đã lấy câu trả lời này từ Anonsage

/** Open another app. 
* @param context current Context, like Activity, App, or Service 
* @param packageName the full package name of the app to open 
* @return true if likely successful, false if unsuccessful 
*/ 
public static boolean openApp(Context context, String packageName) { 
    PackageManager manager = context.getPackageManager(); 
    try { 
     Intent i = manager.getLaunchIntentForPackage(packageName); 
     if (i == null) { 
      return false; 
      //throw new PackageManager.NameNotFoundException(); 
     } 
     i.addCategory(Intent.CATEGORY_LAUNCHER); 
     context.startActivity(i); 
     return true; 
    } catch (PackageManager.NameNotFoundException e) { 
     return false; 
    } 
} 

Để gọi Văn phòng Lens chỉ đơn giản là viết

openApp(this, "com.microsoft.office.officelens"); 

nguồn: Open another application from your own (intent)

+1

Ông có nghĩa là sự xen kẽ giữa ứng dụng này và của riêng mình. Bạn có thực sự nghĩ rằng anh ta có thể lấy kết quả bằng cách sử dụng mã này không? – Vyacheslav

3

Nếu bạn nhìn vào Androidmanifest.xml tập tin, bạn sẽ thấy điều này XML:

<?xml version="1.0" encoding="utf-8" standalone="no"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.microsoft.office.officelens" platformBuildVersionCode="21" platformBuildVersionName="5.0.1-1624448"> 
    <uses-permission android:name="android.permission.CAMERA" android:required="true"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/> 
    <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/> 
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/> 
    <uses-permission android:name="android.permission.READ_CONTACTS"/> 
    <uses-permission android:name="android.permission.READ_PROFILE"/> 
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 
    <uses-permission android:name="android.permission.RECEIVE_SMS"/> 
    <uses-feature android:name="android.hardware.camera" android:required="true"/> 
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> 
    <application android:allowBackup="true" android:icon="@drawable/ic_officelens" android:label="@string/officelens_app_name" android:largeHeap="true" android:name="com.microsoft.office.officelens.OfficeLensApplication" android:theme="@style/OfficeLensAppTheme"> 
     <activity android:label="@string/officelens_app_name" android:name="com.microsoft.office.apphost.LaunchActivity" android:theme="@style/OfficeLensSplashTheme"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 
       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 
     <activity android:configChanges="orientation|screenSize" android:label="@string/officelens_app_name" android:launchMode="singleTask" android:name="com.microsoft.office.officelens.MainActivity" android:theme="@style/FullscreenTheme"/> 
     <activity android:label="@string/officelens_app_name" android:name="com.microsoft.office.officelens.SecureActivity" android:parentActivityName="com.microsoft.office.officelens.MainActivity" android:windowSoftInputMode="stateHidden"/> 
     <activity android:label="@string/title_activity_settings" android:name="com.microsoft.office.officelens.SettingsActivity" android:parentActivityName="com.microsoft.office.officelens.MainActivity"/> 
     <activity android:configChanges="orientation|screenSize" android:label="" android:name="com.microsoft.office.officelens.AboutActivity" android:parentActivityName="com.microsoft.office.officelens.SettingsActivity"/> 
     <activity android:label="" android:name="com.microsoft.office.officelens.FirstRunActivity" android:parentActivityName="com.microsoft.office.officelens.MainActivity" android:screenOrientation="portrait" android:theme="@style/OfficeLensFirstRunTheme"/> 
     <activity android:label="@string/title_activity_section_picker" android:name="com.microsoft.onenote.pickerlib.OneNotePickerActivity" android:theme="@style/Theme.AppCompat.Light"/> 
     <activity android:exported="false" android:icon="@drawable/ms_logo" android:label="@string/webflow_header" android:name="com.microsoft.onlineid.authenticator.AccountAddPendingActivity" android:theme="@style/Theme.MSA"/> 
     <activity android:configChanges="orientation|screenSize" android:exported="false" android:icon="@drawable/ms_logo" android:label="@string/webflow_header" android:name="com.microsoft.onlineid.internal.ui.WebWizardActivity" android:theme="@style/Theme.MSA" android:windowSoftInputMode="adjustResize"> 
      <intent-filter> 
       <action android:name="com.microsoft.onlineid.internal.SIGN_IN"/> 
       <action android:name="com.microsoft.onlineid.internal.RESOLVE_INTERRUPT"/> 
       <category android:name="android.intent.category.DEFAULT"/> 
      </intent-filter> 
     </activity> 
     <activity android:configChanges="orientation|screenSize" android:exported="false" android:icon="@drawable/ms_logo" android:label="@string/webflow_header" android:name="com.microsoft.onlineid.ui.AddAccountActivity" android:theme="@style/Theme.MSA" android:windowSoftInputMode="adjustResize"> 
      <intent-filter> 
       <action android:name="com.microsoft.onlineid.internal.ADD_ACCOUNT"/> 
       <action android:name="com.microsoft.onlineid.internal.SIGN_UP_ACCOUNT"/> 
       <category android:name="android.intent.category.DEFAULT"/> 
      </intent-filter> 
     </activity> 
     <activity android:configChanges="orientation|screenSize" android:exported="false" android:name="com.microsoft.onlineid.ui.SignOutActivity" android:theme="@style/Theme.MSA.Transparent"/> 
     <activity android:exported="false" android:icon="@drawable/ms_logo" android:label="@string/webflow_header" android:name="com.microsoft.onlineid.internal.ui.AccountPickerActivity" android:theme="@style/Theme.MSA.Dialog"> 
      <intent-filter> 
       <action android:name="com.microsoft.onlineid.internal.PICK_ACCOUNT"/> 
       <category android:name="android.intent.category.DEFAULT"/> 
      </intent-filter> 
     </activity> 
     <service android:exported="false" android:name="com.microsoft.onlineid.internal.MsaService"> 
      <intent-filter> 
       <action android:name="com.microsoft.onlineid.internal.GET_TICKET"/> 
       <action android:name="com.microsoft.onlineid.internal.UPDATE_PROFILE"/> 
       <action android:name="com.microsoft.onlineid.internal.SIGN_OUT"/> 
       <action android:name="com.microsoft.onlineid.internal.SIGN_OUT_ALL_APPS"/> 
       <category android:name="android.intent.category.DEFAULT"/> 
      </intent-filter> 
     </service> 
     <service android:enabled="true" android:exported="false" android:name="com.microsoft.onlineid.sso.service.MsaSsoService"> 
      <intent-filter> 
       <action android:name="com.microsoft.msa.action.SSO_SERVICE"/> 
      </intent-filter> 
      <meta-data android:name="com.microsoft.msa.service.sso_version" android:value="1"/> 
      <meta-data android:name="com.microsoft.msa.service.sdk_version" android:value="@string/sdk_version_name"/> 
     </service> 
    </application> 
    <uses-permission android:name="com.android.vending.CHECK_LICENSE"/> 
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/> 
    <uses-permission android:name="android.permission.USE_CREDENTIALS"/> 
    <uses-feature android:name="android.hardware.telephony" android:required="false"/> 
</manifest> 

Nếu bạn đọc kỹ tệp này, bạn sẽ thấy rằng điều này là không thể tương tác với API này. Không phát sóng 'không có' bộ lọc ý định 'thích hợp để tương tác với các ứng dụng khác này.

Điều này là không thể hiện nay.

Dù sao, rõ ràng là bạn có thể lưu vào bộ nhớ cục bộ và truy xuất dữ liệu từ thẻ SD bằng ứng dụng của bạn.

+1

vì vậy cách đóng sẽ bắt đầu ứng dụng tại màn hình MainActivity và cho phép người dùng chia sẻ ảnh đã chụp bằng ứng dụng của riêng tôi? – cyptus

+1

Tôi nghĩ là có. Chia sẻ bộ nhớ trong/bộ nhớ ngoài. – Vyacheslav

Các vấn đề liên quan