Have you declared the redirect uri in the manifest?
Τη Παρασκευή, 8 Ιανουαρίου 2016 - 2:44:39 μ.μ. UTC+2, ο χρήστης Jeff έγραψε:
>
> Hello,
>
> I'm trying to install an APk right after the download is completed. The APk
> gets open with the browser and throws ERR_UNKNOWN_URL_SCHEME. I'm assuming
> the the device thinks the downloaded file needs to be open with the browser
> instead of the android application installer.
>
>
> package com.example.alien.myapplication;
> import android.content.Context;import android.os.Build;import
> android.support.v7.app.AppCompatActivity;
> import java.io.File;import java.io.FileInputStream;import
> java.io.FileNotFoundException;import java.io.IOException;
> import org.json.JSONArray;import org.json.JSONException;import
> org.json.JSONObject;import android.app.DownloadManager;
> import android.net.Uri;import android.os.Bundle;import
> android.os.Environment;import android.os.ParcelFileDescriptor;import
> android.app.Activity;import android.app.DownloadManager;import
> android.app.DownloadManager.Query;import
> android.content.BroadcastReceiver;import android.content.Context;import
> android.content.Intent;import android.content.IntentFilter;import
> android.database.Cursor;import android.view.Gravity;import
> android.view.Menu;import android.view.View;import
> android.view.View.OnClickListener;import android.widget.Button;import
> android.widget.TextView;import android.widget.Toast;
>
> public class MainActivity extends AppCompatActivity implements
> View.OnClickListener {
> private DownloadManager downloadManager;private long downloadReference;
> @Overridepublic void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity_main);
>
> //start download button
> Button startDownload = (Button) findViewById(R.id.startDownload);
> startDownload.setOnClickListener(this);
>
> //set filter to only when download is complete and register broadcast
> receiver
> IntentFilter filter = new
> IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
> registerReceiver(downloadReceiver, filter);}
> public void onClick(View v) {
> System.out.println(v);
>
> switch (v.getId()) {
>
> //start the download process
> case R.id.startDownload:
>
> downloadManager = (DownloadManager)
> getSystemService(DOWNLOAD_SERVICE);
> Uri Download_Uri = Uri.parse("http://45.63.4.194/es.apk");
> DownloadManager.Request request = new
> DownloadManager.Request(Download_Uri);
>
> //Set a description of this download, to be displayed in
> notifications (if enabled)
> request.setDescription("Android Data download using
> DownloadManager.");
> //Set the local destination for the downloaded file to a path
> within the application's external files directory
> request.setDestinationInExternalFilesDir(this, null, "es.apk");
>
> //Enqueue a new download and same the referenceId
> downloadReference = downloadManager.enqueue(request);
> break;
> }}
> private BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
>
> @Override
> public void onReceive(Context context, Intent intent) {
> long referenceId =
> intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
> if(downloadReference == referenceId) {
>
> DownloadManager dm = (DownloadManager)
> getSystemService(DOWNLOAD_SERVICE);
> intent = new Intent(Intent.ACTION_VIEW);
>
>
> intent.setDataAndType(dm.getUriForDownloadedFile(referenceId),
> dm.getMimeTypeForDownloadedFile(referenceId));
> startActivity(intent);
>
> }
> }};}
>
>
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/dac49bc9-c048-488f-bb7e-2bce70f37eba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.