微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.content.Context的实例源码

项目:@H_404_2@LaunchEnr    文件:@H_404[email protected]   
@H_404_7@
@Override
public void onReceive(final Context context,Intent intent) {
    if (AppWidgetManager.ACTION_APPWIDGET_HOST_RESTORED.equals(intent.getAction())) {
        final int[] oldIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_OLD_IDS);
        final int[] newIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
        if (oldIds.length == newIds.length) {
            final PendingResult asyncResult = goAsync();
            new Handler(LauncherModel.getWorkerLooper())
                    .postAtFrontOfQueue(new Runnable() {
                        @Override
                        public void run() {
                            restoreAppWidgetIds(context,asyncResult,oldIds,newIds);
                        }
                    });
        }
    }
}
项目:@H_404_2@Android-DFU-App    文件:@H_404[email protected]   
@H_404_7@
@Override
public void onReceive(final Context context,final Intent intent) {
    final String action = intent.getAction();

    if (RSCService.broADCAST_RSC_MEASUREMENT.equals(action)) {
        final float speed = intent.getFloatExtra(RSCService.EXTRA_SPEED,0.0f);
        final int cadence = intent.getIntExtra(RSCService.EXTRA_CADENCE,0);
        final float totaldistance = intent.getFloatExtra(RSCService.EXTRA_TOTAL_disTANCE,RSCManagerCallbacks.NOT_AVAILABLE);
        final int activity = intent.getIntExtra(RSCService.EXTRA_ACTIVITY,RSCManagerCallbacks.ACTIVITY_WALKING);
        // Update GUI
        onMeasurementReceived(speed,cadence,totaldistance,activity);
    } else if (RSCService.broADCAST_STRIDES_UPDATE.equals(action)) {
        final int strides = intent.getIntExtra(RSCService.EXTRA_STRIDES,0);
        final float distance = intent.getFloatExtra(RSCService.EXTRA_disTANCE,0);
        // Update GUI
        onStripesUpdate(distance,strides);
    }
}
项目:@H_404_2@stynico    文件:@H_404[email protected]   
@H_404_7@
private void setUp(Context context,AttributeSet attrs)
  {
      TypedArray a =context.obtainStyledAttributes(attrs,R.styleable.CoolImageView);
      String direction=a.getString(R.styleable.CoolImageView_direction);
      if (direction == null)
      {
          throw new RuntimeException("You don't set direction properties,If you don't want to do that." +
                               "You can use ordinary ImageView instead");
      }
else if (direction.equals("vertical"))
      {
          isSetVerticalMove = true;
      }
      else if (direction.equals("horizontal"));
      else
      {
          throw new RuntimeException("Direction attribute set is not valid,It is only allowed to set to vertical or horizontal");
      }
      mDrawable = getDrawable();
      mHandler = new MoveHandler();
      mHandler.sendEmptyMessageDelayed(1,220L);

  }
项目:@H_404_2@miaosou    文件:@H_404[email protected]   
@H_404_7@
public static void setupPay(Context cxt,Config config) {
    Intent i = new Intent(cxt,ZhiActivity.class);
    i.putExtra(EXTRA_KEY_PAY_CONfig,config);
    cxt.startActivity(i);
}
项目:@H_404_2@Customerly-Android-SDK    文件:@H_404_2@IAct_AInput.java   
@H_404_7@
@Override
public void onReceive(Context context,Intent intent) {
    boolean connected = IU_Utils.checkConnection(context);
    if(connected) {
        if(this.attendingReconnection) {
            this.attendingReconnection = false;
            onReconnection();
        }
    } else {
        this.attendingReconnection = true;
    }
}
项目:@H_404_2@SweepRobot    文件:@H_404[email protected]   
@H_404_7@
/**
 * isWifi
 *
 * @param context
 * @return boolean
 */
public static boolean isWifi(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
    if (activeNetInfo != null
            && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
        return true;
    }
    return false;
}
项目:@H_404_2@LaravelNewsApp    文件:@H_404[email protected]   
@H_404_7@
/**
 * Handles the server error,tries to determine whether to show a stock message or to
 * show a message retrieved from the server.
 *
 * @param err Volley error
 * @param context Context
 * @return String
 */
private static String handleServerError(Object err,Context context) {
    VolleyError error = (VolleyError) err;

    NetworkResponse response = error.networkResponse;

    if (response != null) {
        switch (response.statusCode) {
            case 404:
            case 422:
            case 400:
            case 401:

                try {
                    String string = new String(error.networkResponse.data);
                    JSONObject object = new JSONObject(string);
                    if (object.has("message")) {
                        return object.get("message").toString();
                    }
                    else if(object.has("error_description")) {
                        return object.get("error_description").toString();
                    }
                }catch (JSONException e)
                {
                    return "Could not parse response";
                }
                // invalid request
                return error.getMessage();

            default:
                return ERR_UNKNowN_STATUS_CODE;
        }
    }
    return ERR_GENERIC;
}
项目:@H_404_2@Boilerplate    文件:@H_404[email protected]   
@H_404_7@
public static void start(Context context,String subscriber,String url,int requestType) {
    Intent intent = new Intent(context,TlIntentService.class);
    intent.putExtra(Extra.SUBSCRIBER,subscriber);
    intent.putExtra(Extra.URL,url);
    intent.putExtra(Extra.REQUEST_TYPE,requestType);
    context.startService(intent);
}
项目:@H_404_2@discogsbrowser    文件:@H_404[email protected]   
@H_404_7@
public static Drawable getDrawable(Context context,int id){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return context.getDrawable(id);
    } else {
        return context.getResources().getDrawable(id);
    }

}
项目:@H_404_2@BlackList    文件:@H_404[email protected]   
@H_404_7@
@Nullable
private SMSMessageCursorWrapper getSMSMessagesByThreadId(Context context,int threadId,boolean desc,int limit) {
    if (!Permissions.isGranted(context,Permissions.READ_SMS) ||
            !Permissions.isGranted(context,Permissions.READ_CONTACTS)) {
        return null;
    }

    String orderClause = (desc ? DATE + " DESC " : DATE + " ASC ");
    String limitClause = (limit > 0 ? " LIMIT " + limit : "");
    Cursor cursor = contentResolver.query(
            URI_CONTENT_SMS,null,THREAD_ID + " = ? " +
                    // we don't support drafts yet
                    " AND " + ADDRESS + " NOT NULL ",new String[]{String.valueOf(threadId)},orderClause + limitClause);

    return (validate(cursor) ? new SMSMessageCursorWrapper(cursor) : null);
}
项目:@H_404_2@Cable-Android    文件:@H_404[email protected]   
@H_404_7@
public static @NonNull IdentityKeyPair getIdentityKeyPair(@NonNull Context context) {
  if (!hasIdentityKey(context)) throw new AssertionError("There isn't one!");

  try {
    IdentityKey  publicKey  = getIdentityKey(context);
    ECPrivateKey privateKey = Curve.decodePrivatePoint(Base64.decode(retrieve(context,IDENTITY_PRIVATE_KEY_PREF)));

    return new IdentityKeyPair(publicKey,privateKey);
  } catch (IOException e) {
    throw new AssertionError(e);
  }
}
项目:@H_404_2@PADC-SFC-News    文件:@H_404[email protected]   
@H_404_7@
public EmptyViewPod(Context context) {
    super(context);
}
项目:@H_404_2@android-dev-challenge    文件:@H_404[email protected]   
@H_404_7@
/**
 * This method will format the temperatures to be displayed in the
 * following form: "HIGH° / LOW°"
 *
 * @param context Android Context to access preferences and resources
 * @param high    High temperature for a day in user's preferred units
 * @param low     Low temperature for a day in user's preferred units
 *
 * @return String in the form: "HIGH° / LOW°"
 */
public static String formatHighLows(Context context,double high,double low) {
    long roundedHigh = Math.round(high);
    long roundedLow = Math.round(low);

    String formattedHigh = formatTemperature(context,roundedHigh);
    String formattedLow = formatTemperature(context,roundedLow);

    String highLowStr = formattedHigh + " / " + formattedLow;
    return highLowStr;
}
项目:@H_404_2@CalendarView_master    文件:@H_404[email protected]   
@H_404_7@
public MonthRecyclerView(Context context,@Nullable AttributeSet attrs) {
    super(context,attrs);
    mAdapter = new MonthAdapter(context);
    setLayoutManager(new GridLayoutManager(context,3));
    setAdapter(mAdapter);
    mAdapter.setonItemClickListener(new BaseRecyclerAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(int position,long itemId) {
            if (mListener != null) {
                Month month = mAdapter.getItem(position);
                mListener.onMonthSelected(month.getYear(),month.getMonth());
            }
        }
    });
}
项目:@H_404_2@letv    文件:@H_404[email protected]   
@H_404_7@
FragmentHostCallback(Activity activity,Context context,Handler handler,int windowAnimations) {
    this.mFragmentManager = new FragmentManagerImpl();
    this.mActivity = activity;
    this.mContext = context;
    this.mHandler = handler;
    this.mWindowAnimations = windowAnimations;
}
项目:@H_404_2@ThunderMusic    文件:@H_404[email protected]   
@H_404_7@
public static Library readAdapter(Context context,String name)
        throws IOException,ClassNotFoundException {
    String path = (context
            .getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) + "/.Thunder_Music/.online");
    File file = new File(path,name);
    FileInputStream fin = new FileInputStream(file);
    ObjectInputStream ois = new ObjectInputStream(fin);
    Library library = (Library) ois.readobject();
    ois.close();

    return library;
}
项目:@H_404_2@downloadmanager    文件:@H_404_2@RealSystemFacade.java   
@H_404_7@
@Override
public NetworkInfo getActiveNetworkInfo() {
    ConnectivityManager connectivity =
            (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity == null) {
        Log.w(TAG,"Couldn't get connectivity manager");
        return null;
    }

    final NetworkInfo activeInfo = connectivity.getActiveNetworkInfo();
    if (activeInfo == null && Constants.LOGVV) {
        Log.v(TAG,"network is not available");
    }
    return activeInfo;
}
项目:@H_404_2@Blogg    文件:@H_404[email protected]   
@H_404_7@
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("thenewpotato.blogg",appContext.getPackageName());
}
项目:@H_404_2@BaseCore    文件:@H_404[email protected]   
@H_404_7@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        View v = getCurrentFocus();
        if (isShouldHideKeyboard(v,ev)) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getwindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
    return super.dispatchTouchEvent(ev);
}
项目:@H_404_2@ultrasonic    文件:@H_404_2@JukeBoxService.java   
@H_404_7@
public Volumetoast(Context context)
{
    super(context);
    setDuration(Toast.LENGTH_SHORT);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.jukeBox_volume,null);
    progressBar = (ProgressBar) view.findViewById(R.id.jukeBox_volume_progress_bar);
    setView(view);
    setGravity(Gravity.TOP,0);
}
项目:@H_404_2@GitHub    文件:@H_404[email protected]   
@H_404_7@
private String getDescriptionNoUpdate(Context context) {
    if (descriptionNoUpdate == null) {
        return String.format(context.getResources().getString(R.string.appupdater_update_not_available_description),UtilsLibrary.getAppName(context));
    } else {
        return descriptionNoUpdate;
    }
}
项目:@H_404_2@Saiy-PS    文件:@H_404[email protected]   
@H_404_7@
public SaiyAssets(final Context context) throws IOException {
        super(context);

//        File appDir = context.getExternalFilesDir(null);
//        if (null == appDir)
//            throw new IOException("cannot get external files dir,"
//                    + "external storage state is " + Environment.getExternalStorageState());
//        externalDir = new File(appDir,SYNC_DIR);
//        assetManager = context.getAssets();
    }
项目:@H_404_2@letv    文件:@H_404[email protected]   
@H_404_7@
public static void launch(Context activity,int from,String title,String icon,String liveUrl,int launchMode,String staticsId,String fragId,String desc) {
    LogInfo.log("fornia","share forlepai---SharePageactivity launch");
    Intent intent = new Intent(activity,SharePageActivity.class);
    intent.putExtra("from",from);
    intent.putExtra("launchMode",launchMode);
    intent.putExtra("title",title);
    intent.putExtra(WidgetRequestParam.REQ_ParaM_COMMENT_CONTENT,desc);
    intent.putExtra(SettingsJsonConstants.APP_ICON_KEY,icon);
    intent.putExtra("liveUrl",liveUrl);
    intent.putExtra("staticsId",staticsId);
    intent.putExtra("fragId",fragId);
    activity.startActivity(intent);
}
项目:@H_404_2@Hello-Music-droid    文件:@H_404[email protected]   
@H_404_7@
public static final int getSongCountForPlaylist(final Context context,final long playlistId) {
    Cursor c = context.getContentResolver().query(
            MediaStore.Audio.Playlists.Members.getContentUri("external",playlistId),new String[]{BaseColumns._ID},MUSIC_ONLY_SELECTION,null);

    if (c != null) {
        int count = 0;
        if (c.movetoFirst()) {
            count = c.getCount();
        }
        c.close();
        c = null;
        return count;
    }

    return 0;
}
项目:@H_404_2@Camera-Roll-Android-App    文件:@H_404[email protected]   
@H_404_7@
public static void addExcludedpath(Context context,String path) {
    if (excludedpaths == null) {
        excludedpaths = loadExcludedpaths(context);
    }
    if (!excludedpaths.contains(path)) {
        excludedpaths.add(path);
    }
}
项目:@H_404_2@Hotspot-master-devp    文件:@H_404[email protected]   
@H_404_7@
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context,ScrollingListener listener) {
    gestureDetector = new GestureDetector(context,gestureListener);
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
项目:@H_404_2@TaipeiTechRefined    文件:@H_404[email protected]   
@H_404_7@
public static void showNotification(Context context,String message,boolean is_hint) {
    if (context == null) {
        return;
    }
    NotificationCompat.Builder builder = new NotificationCompat.Builder(
            context);
    builder.setStyle(
            new NotificationCompat
                    .BigTextStyle(builder)
                    .bigText(message)
                    .setBigContentTitle(title))
            .setContentTitle(title)
            .setContentText(message)
            .setSmallIcon(R.drawable.ic_notification)
            .setTicker(message);
    Intent intent = new Intent(context,MainActivity.class);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    TaskStackBuilder stack_builder = TaskStackBuilder.create(context);
    stack_builder.addParentStack(MainActivity.class);
    stack_builder.addNextIntent(intent);
    PendingIntent pending_intent = stack_builder
            .getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pending_intent);
    notificationmanager notify_manager = (notificationmanager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notify_manager.notify(is_hint ? hint_notification_index
            : notification_index,builder.build());
    if (!is_hint) {
        notification_index++;
    }
}
项目:@H_404_2@tenor-android-demo-search    文件:@H_404_2@AbstractDrawableutils.java   
@H_404_7@
/**
 * Sets a tint on top of the desired drawable
 *
 * @param context        the context
 * @param drawable       source drawable to apply the tint
 * @param tintColorResId color res id of the desired tint
 */
public static void setDrawableTint(@Nullable final Context context,@NonNull final Drawable drawable,@ColorRes final int tintColorResId) {
    if (context == null || drawable == null) {
        throw new IllegalArgumentException("inputs cannot be null,context: " + context
                + ",drawable: " + drawable);
    }
    setDrawableTint(drawable,AbstractColorUtils.getColor(context,tintColorResId));
}
项目:@H_404_2@VideoCRE    文件:@H_404[email protected]   
@H_404_7@
@Override
public void initialize(SurfaceTextureHelper surfaceTextureHelper,Context applicationContext,CapturerObserver capturerObserver) {
  this.applicationContext = applicationContext;
  this.capturerObserver = capturerObserver;
  this.surfaceHelper = surfaceTextureHelper;
  this.cameraThreadHandler =
      surfaceTextureHelper == null ? null : surfaceTextureHelper.getHandler();
}
项目:@H_404_2@boohee_v5.6    文件:@H_404[email protected]   
@H_404_7@
public static void setIconBadge(Context context,int count) {
    try {
        if (!Build.MANUFACTURER.equalsIgnoreCase(MiBandHelper.KEY_DATA_SOURCE)) {
            if (Build.MANUFACTURER.equalsIgnoreCase(LeakCanaryInternals.SAMSUNG)) {
                setToSamsumg(context,count);
            } else if (Build.MANUFACTURER.toLowerCase().contains("sony")) {
                setToSony(context,count);
            }
        }
    } catch (Exception e) {
        e.printstacktrace();
    }
}
项目:@H_404_2@PicShow-zhaipin    文件:@H_404_2@JcmediaManager.java   
@H_404_7@
public void prepare(final Context context,final String url,final Map<String,String> mapHeadData,boolean loop) {
    if (TextUtils.isEmpty(url)) return;
    releaseMediaPlayer();
    Message msg = new Message();
    msg.what = HANDLER_PREPARE;
    FuckBean fb = new FuckBean(context,url,mapHeadData,loop);
    msg.obj = fb;
    mMediaHandler.sendMessage(msg);
}
项目:@H_404_2@Android-skin-support    文件:@H_404[email protected]   
@H_404_7@
private ColorStateList getTintListFromCache(@NonNull Context context,@DrawableRes int resId) {
    if (mTintLists != null) {
        final SparseArray<ColorStateList> tints = mTintLists.get(context);
        return tints != null ? tints.get(resId) : null;
    }
    return null;
}
项目:@H_404_2@Skeleton    文件:@H_404_2@SkeletonGroup.java   
@H_404_7@
public SkeletonGroup(@NonNull Context context) {
    super(context);
}
项目:@H_404_2@SearchLayout    文件:@H_404[email protected]   
@H_404_7@
public static int dip2px(Context context,float dpValue) {
    final float scale = context.getResources().getdisplayMetrics().density;
    return (int) (dpValue * scale + 0.5f);
}
项目:@H_404_2@MyLoadingButton    文件:@H_404[email protected]   
@H_404_7@
public MyLoadingButton(Context context,AttributeSet attrs) {
    super(context,attrs);

    initView();
    setAttrs(attrs,context);
}
项目:@H_404_2@android-instant-apps    文件:@H_404[email protected]   
@H_404_7@
/**
 * Constructor used from XML.
 */
public TextResize(Context context,attrs);
    addTarget(TextView.class);
}
项目:@H_404_2@Android-skin-support    文件:@H_404[email protected]   
@H_404_7@
public static int getColorPrimaryDarkResId(Context context) {
    return getResId(context,APPCOMPAT_COLOR_PRIMARY_DARK_ATTRS);
}
项目:@H_404_2@cwac-document    文件:@H_404[email protected]   
@H_404_7@
public static Uri createFile(Context context,Uri self,String mimeType,String displayName) {
    return DocumentsContract.createDocument(context.getContentResolver(),self,mimeType,displayName);
}
项目:@H_404_2@Android-Open-Shopping-List    文件:@H_404[email protected]   
@H_404_7@
@Override
public void onAttach(Context context) {
    super.onAttach(context);

    listener = (ItemDialogListener) context;
}
项目:@H_404_2@Beach-Android    文件:@H_404[email protected]   
@H_404_7@
public static void clearNotifications(Context context,int nId) {
    notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationmanager.cancel(nId);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。