Search in sources :

Example 66 with Uri

use of android.net.Uri in project enroscar by stanfy.

the class StreamingPlaybackImpl method getCurrentTrackInfo.

@Override
public Bundle getCurrentTrackInfo() throws RemoteException {
    final Bundle bundle = new Bundle();
    if (service.getAlbum() != null) {
        bundle.putString(StreamingPlaybackService.EXTRA_TRACK_ALBUM, service.getAlbum());
    }
    if (service.getAuthor() != null) {
        bundle.putString(StreamingPlaybackService.EXTRA_TRACK_AUTHOR, service.getAuthor());
    }
    if (service.getTitle() != null) {
        bundle.putString(StreamingPlaybackService.EXTRA_TRACK_TITLE, service.getTitle());
    }
    final Uri uri = getCurrentUrl();
    if (uri != null) {
        bundle.putParcelable(StreamingPlaybackService.EXTRA_TRACK_URL, uri);
    }
    return bundle;
}
Also used : Bundle(android.os.Bundle) Uri(android.net.Uri)

Example 67 with Uri

use of android.net.Uri in project platform_frameworks_base by android.

the class PackageMonitor method getPackageName.

String getPackageName(Intent intent) {
    Uri uri = intent.getData();
    String pkg = uri != null ? uri.getSchemeSpecificPart() : null;
    return pkg;
}
Also used : Uri(android.net.Uri)

Example 68 with Uri

use of android.net.Uri in project platform_frameworks_base by android.

the class DownloadManagerBaseTest method doEnqueue.

private long doEnqueue(int location) throws Exception {
    Uri uri = getServerUri(DEFAULT_FILENAME);
    Request request = new Request(uri).setTitle(DEFAULT_FILENAME);
    if (location == DOWNLOAD_TO_SYSTEM_CACHE) {
        request.setDestinationToSystemCache();
    }
    return mDownloadManager.enqueue(request);
}
Also used : Request(android.app.DownloadManager.Request) Uri(android.net.Uri)

Example 69 with Uri

use of android.net.Uri in project platform_frameworks_base by android.

the class DownloadManagerFunctionalTest method testDownloadToExternal.

/**
     * Tests trying to download a file to SD card.
     */
@LargeTest
public void testDownloadToExternal() throws Exception {
    String localDownloadDirectory = Environment.getExternalStorageDirectory().getPath();
    File downloadedFile = new File(localDownloadDirectory, DEFAULT_FILENAME);
    // make sure the file doesn't already exist in the directory
    downloadedFile.delete();
    try {
        byte[] blobData = generateData(DEFAULT_FILE_SIZE, DataType.TEXT);
        // Prepare the mock server with a standard response
        enqueueResponse(buildResponse(HTTP_OK, blobData));
        Uri uri = getServerUri(DEFAULT_FILENAME);
        Request request = new Request(uri);
        Uri localUri = Uri.fromFile(downloadedFile);
        request.setDestinationUri(localUri);
        long dlRequest = mDownloadManager.enqueue(request);
        // wait for the download to complete
        waitForDownloadOrTimeout(dlRequest);
        verifyAndCleanupSingleFileDownload(dlRequest, blobData);
        assertEquals(1, mReceiver.numDownloadsCompleted());
    } finally {
        downloadedFile.delete();
    }
}
Also used : Request(android.app.DownloadManager.Request) File(java.io.File) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 70 with Uri

use of android.net.Uri in project platform_frameworks_base by android.

the class DownloadManagerFunctionalTest method testDownloadNoWifi.

/**
     * Tests that a download set for Wifi does not progress while Wifi is disabled, but resumes
     * once Wifi is re-enabled.
     */
@LargeTest
public void testDownloadNoWifi() throws Exception {
    // wait only 60 seconds before giving up
    long timeout = 60 * 1000;
    // 140k
    int fileSize = 1024;
    byte[] blobData = generateData(fileSize, DataType.TEXT);
    setWiFiStateOn(false);
    enqueueResponse(buildResponse(HTTP_OK, blobData));
    try {
        Uri uri = getServerUri(DEFAULT_FILENAME);
        Request request = new Request(uri);
        request.setAllowedNetworkTypes(Request.NETWORK_WIFI);
        long dlRequest = mDownloadManager.enqueue(request);
        // wait for the download to complete
        boolean success = waitForDownloadOrTimeoutNoThrow(dlRequest, WAIT_FOR_DOWNLOAD_POLL_TIME, timeout);
        assertFalse("Download proceeded without Wifi connection!", success);
        setWiFiStateOn(true);
        waitForDownloadOrTimeout(dlRequest);
        assertEquals(1, mReceiver.numDownloadsCompleted());
    } finally {
        setWiFiStateOn(true);
    }
}
Also used : Request(android.app.DownloadManager.Request) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

Uri (android.net.Uri)3406 Intent (android.content.Intent)732 Cursor (android.database.Cursor)466 ContentValues (android.content.ContentValues)349 File (java.io.File)339 IOException (java.io.IOException)254 ContentResolver (android.content.ContentResolver)242 ArrayList (java.util.ArrayList)209 Test (org.junit.Test)194 RemoteException (android.os.RemoteException)190 Bundle (android.os.Bundle)154 Bitmap (android.graphics.Bitmap)129 Context (android.content.Context)118 InputStream (java.io.InputStream)110 PendingIntent (android.app.PendingIntent)104 LargeTest (android.test.suitebuilder.annotation.LargeTest)97 View (android.view.View)95 FileNotFoundException (java.io.FileNotFoundException)94 Request (android.app.DownloadManager.Request)83 TextView (android.widget.TextView)73