Search in sources :

Example 51 with Context

use of android.content.Context in project VirtualApp by asLody.

the class ServiceManagerNative method getServiceFetcher.

private static IServiceFetcher getServiceFetcher() {
    if (sFetcher == null) {
        synchronized (ServiceManagerNative.class) {
            if (sFetcher == null) {
                Context context = VirtualCore.get().getContext();
                Bundle response = new ProviderCall.Builder(context, SERVICE_CP_AUTH).methodName("@").call();
                if (response != null) {
                    IBinder binder = BundleCompat.getBinder(response, "_VA_|_binder_");
                    linkBinderDied(binder);
                    sFetcher = IServiceFetcher.Stub.asInterface(binder);
                }
            }
        }
    }
    return sFetcher;
}
Also used : Context(android.content.Context) IBinder(android.os.IBinder) Bundle(android.os.Bundle)

Example 52 with Context

use of android.content.Context in project FileDownloaderManager by arlyxiao.

the class FileDownloader method register_done_receiver.

private void register_done_receiver() {
    download_done_receiver = new DownloadDoneNotification() {

        @Override
        public void onReceive(Context ctxt, Intent intent) {
            fd = intent.getParcelableExtra("download_manager");
            if (fd.get_obj_id() == FileDownloader.this.get_obj_id()) {
                // if (fd.download_url == FileDownloader.this.download_url) {
                Log.i("调试 接收正在下载的 downloaded_size 值 ", Integer.toString(fd.downloaded_size));
                FileDownloader.this.downloaded_size = 0;
                FileDownloader.this.file_size = 0;
                Log.i("调试 接收正在下载的 file_size 值 ", Integer.toString(fd.file_size));
            } else {
                Log.i("调试 广播接收到不同的 obj_id 2 ", Integer.toString(fd.get_obj_id()));
            }
        }
    };
    context.registerReceiver(download_done_receiver, new IntentFilter("app.action.download_done_notification"));
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent)

Example 53 with Context

use of android.content.Context in project FileDownloaderManager by arlyxiao.

the class FileDownloader method register_pause_receiver.

private void register_pause_receiver() {
    download_pause_receiver = new DownloadPauseReceiver() {

        @Override
        public void onReceive(Context ctxt, Intent intent) {
            fd = intent.getParcelableExtra("download_manager");
            if (fd.get_obj_id() == FileDownloader.this.get_obj_id()) {
                // if (fd.download_url == FileDownloader.this.download_url) {
                Log.i("调试 pause 接收正在下载的 downloaded_size 值 ", Integer.toString(fd.downloaded_size));
                FileDownloader.this.downloaded_size = 0;
                FileDownloader.this.file_size = 0;
                Log.i("调试 pause 接收正在下载的 file_size 值 ", Integer.toString(fd.file_size));
            } else {
                Log.i("调试 广播接收到不同的 obj_id 3 ", Integer.toString(fd.get_obj_id()));
            }
        }
    };
    context.registerReceiver(download_pause_receiver, new IntentFilter("app.action.download_pause_receiver"));
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent)

Example 54 with Context

use of android.content.Context in project FileDownloaderManager by arlyxiao.

the class FileDownloader method register_stop_receiver.

private void register_stop_receiver() {
    download_stop_receiver = new DownloadStopReceiver() {

        @Override
        public void onReceive(Context ctxt, Intent intent) {
            fd = intent.getParcelableExtra("download_manager");
            if (fd.get_obj_id() == FileDownloader.this.get_obj_id()) {
                // if (fd.download_url == FileDownloader.this.download_url) {
                Log.i("调试 stop 接收正在下载的 downloaded_size 值 ", Integer.toString(fd.downloaded_size));
                FileDownloader.this.downloaded_size = 0;
                FileDownloader.this.file_size = 0;
                Log.i("调试 stop 接收正在下载的 file_size 值 ", Integer.toString(fd.file_size));
            } else {
                Log.i("调试 stop 广播接收到不同的 obj_id 4 ", Integer.toString(fd.get_obj_id()));
            }
        }
    };
    context.registerReceiver(download_stop_receiver, new IntentFilter("app.action.download_stop_receiver"));
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent)

Example 55 with Context

use of android.content.Context in project enroscar by stanfy.

the class ImageConsumerTest method consumerShouldReturnRequiredSizeRespectingScreenDimensions.

@Test
public void consumerShouldReturnRequiredSizeRespectingScreenDimensions() {
    ImageConsumer consumer = new Consumer(0, 0);
    Context context = Robolectric.application;
    assertThat(consumer.getRequiredWidth()).isEqualTo(context.getResources().getDisplayMetrics().widthPixels);
    assertThat(consumer.getRequiredHeight()).isEqualTo(context.getResources().getDisplayMetrics().heightPixels);
}
Also used : Context(android.content.Context) Test(org.junit.Test)

Aggregations

Context (android.content.Context)3233 Intent (android.content.Intent)676 View (android.view.View)400 Test (org.junit.Test)346 BroadcastReceiver (android.content.BroadcastReceiver)338 IntentFilter (android.content.IntentFilter)301 TextView (android.widget.TextView)258 Resources (android.content.res.Resources)226 PendingIntent (android.app.PendingIntent)188 PackageManager (android.content.pm.PackageManager)164 File (java.io.File)156 IOException (java.io.IOException)150 LayoutInflater (android.view.LayoutInflater)139 ImageView (android.widget.ImageView)135 Drawable (android.graphics.drawable.Drawable)128 Uri (android.net.Uri)115 RemoteException (android.os.RemoteException)102 ArrayList (java.util.ArrayList)102 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)101 Bundle (android.os.Bundle)95