android.content.Intent.getLongExtra()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(412)

本文整理了Java中android.content.Intent.getLongExtra()方法的一些代码示例,展示了Intent.getLongExtra()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getLongExtra()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getLongExtra

Intent.getLongExtra介绍

暂无

代码示例

代码示例来源:origin: Tencent/tinker

public static long getIntentPatchCostTime(Intent intent) {
  return intent.getLongExtra(INTENT_PATCH_COST_TIME, 0);
}

代码示例来源:origin: Tencent/tinker

public static long getLongExtra(Intent intent, String name, long defaultValue) {
  if (null == intent) {
    return defaultValue;
  }
  long ret = defaultValue;
  try {
    ret = intent.getLongExtra(name, defaultValue);
  } catch (Exception e) {
    Log.e(TAG, "getIntExtra exception:" + e.getMessage());
    ret = defaultValue;
  }
  return ret;
}

代码示例来源:origin: googlesamples/android-testing

@Override
public IBinder onBind(Intent intent) {
  // If the Intent comes with a seed for the number generator, apply it.
  if (intent.hasExtra(SEED_KEY)) {
    mSeed = intent.getLongExtra(SEED_KEY, 0);
    mGenerator.setSeed(mSeed);
  }
  return mBinder;
}

代码示例来源:origin: nickbutcher/plaid

@Override
protected void onHandleIntent(Intent intent) {
  if (intent != null) {
    final String action = intent.getAction();
    if (ACTION_UPVOTE.equals(action)) {
      handleActionUpvote(intent.getLongExtra(EXTRA_STORY_ID, 0L));
    }
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@SuppressLint("DefaultLocale")
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  TextView row=
    (TextView)super.getView(position, convertView, parent);
  Intent event=getItem(position);
  Date date=new Date(event.getLongExtra(EXTRA_TIME, 0));
  row.setText(String.format("%s = %x", fmt.format(date),
               event.getIntExtra(EXTRA_RANDOM, -1)));
  return(row);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 public View getView(int position, View convertView, ViewGroup parent) {
  TextView row=(TextView)super.getView(position, convertView, parent);
  Intent event=getItem(position);
  row.setText(String.format("%s : %s",
   fmt.format(event.getLongExtra(TestReceiver.EXTRA_TIME, 0)),
   getEventLabel(event)));
  return(row);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onReceive(Context ctxt, Intent i) {
 boolean isDownload=i.getBooleanExtra(EXTRA_IS_DOWNLOAD, false);
 DemoScheduledService.enqueueWork(ctxt,
   new Intent(ctxt, DemoScheduledService.class)
     .putExtra(EXTRA_IS_DOWNLOAD, isDownload));
 long period=i.getLongExtra(EXTRA_PERIOD, -1);
 if (period>0) {
  scheduleExactAlarm(ctxt,
    (AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE),
    period, isDownload);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onReceive(Context ctxt, Intent i) {
 boolean isDownload=i.getBooleanExtra(EXTRA_IS_DOWNLOAD, false);
 DemoScheduledService.enqueueWork(ctxt,
   new Intent(ctxt, DemoScheduledService.class)
     .putExtra(EXTRA_IS_DOWNLOAD, isDownload));
 long period=i.getLongExtra(EXTRA_PERIOD, -1);
 if (period>0) {
  scheduleExactAlarm(ctxt,
    (AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE),
    period, isDownload);
 }
}

代码示例来源:origin: TommyLemon/Android-ZBLibrary

@Override
public void initData() {//必须在onCreate方法内调用
  //示例代码<<<<<<<<
  demoFragment = DemoFragment.createInstance(getIntent().getLongExtra(INTENT_USER_ID, 0));
  fragmentManager
  .beginTransaction()
  .add(R.id.flDemoFragmentActivityContainer, demoFragment)
  .show(demoFragment)
  .commit();
  //示例代码>>>>>>>>
}

代码示例来源:origin: TommyLemon/APIJSON

public void onReceive(Context context, Intent intent) {
    String action = intent == null ? null : intent.getAction();
    if (isAlive() == false || StringUtil.isNotEmpty(action, true) == false) {
      Log.e(TAG, "receiver.onReceive  isAlive() == false" +
          " || StringUtil.isNotEmpty(action, true) == false >> return;");
      return;
    }
    if (ActionUtil.ACTION_USER_CHANGED.equals(action)) {
      if (isCurrentUser(intent.getLongExtra(INTENT_ID, 0))) {
        invalidate();
      }
    }
  }
};

代码示例来源:origin: TommyLemon/APIJSON

public void onReceive(Context context, Intent intent) {
    String action = intent == null ? null : intent.getAction();
    if (isAlive() == false || StringUtil.isNotEmpty(action, true) == false) {
      Log.e(TAG, "receiver.onReceive  isAlive() == false" +
          " || StringUtil.isNotEmpty(action, true) == false >> return;");
      return;
    }
    if (ActionUtil.ACTION_USER_CHANGED.equals(action)) {
      if (isCurrentUser(intent.getLongExtra(INTENT_ID, 0))) {
        invalidate();
      }
    }
  }
};

代码示例来源:origin: TommyLemon/APIJSON

public void onReceive(Context context, Intent intent) {
    String action = intent == null ? null : intent.getAction();
    if (isAlive() == false || StringUtil.isNotEmpty(action, true) == false) {
      Log.e(TAG, "receiver.onReceive  isAlive() == false" +
          " || StringUtil.isNotEmpty(action, true) == false >> return;");
      return;
    }
    if (ActionUtil.ACTION_USER_CHANGED.equals(action)) {
      if (isCurrentUser(intent.getLongExtra(INTENT_ID, 0))) {
        invalidate();
      }
    }
  }
};

代码示例来源:origin: TommyLemon/APIJSON

public void onReceive(Context context, Intent intent) {
    String action = intent == null ? null : intent.getAction();
    if (isAlive() == false || StringUtil.isNotEmpty(action, true) == false) {
      Log.e(TAG, "receiver.onReceive  isAlive() == false" +
          " || StringUtil.isNotEmpty(action, true) == false >> return;");
      return;
    }
    if (ActionUtil.ACTION_USER_CHANGED.equals(action)) {
      if (isCurrentUser(intent.getLongExtra(INTENT_ID, 0))) {
        invalidate();
      }
    }
  }
};

代码示例来源:origin: TommyLemon/APIJSON

public void onReceive(Context context, Intent intent) {
    String action = intent == null ? null : intent.getAction();
    if (isAlive() == false || StringUtil.isNotEmpty(action, true) == false) {
      Log.e(TAG, "receiver.onReceive  isAlive() == false" +
          " || StringUtil.isNotEmpty(action, true) == false >> return;");
      return;
    }
    if (ActionUtil.ACTION_USER_CHANGED.equals(action)) {
      if (isCurrentUser(intent.getLongExtra(INTENT_ID, 0))) {
        invalidate();
      }
    }
  }
};

代码示例来源:origin: robolectric/robolectric

@Test
public void testLongExtra() throws Exception {
 Intent intent = new Intent();
 assertSame(intent, intent.putExtra("foo", 2L));
 assertEquals(2L, intent.getExtras().get("foo"));
 assertEquals(2L, intent.getLongExtra("foo", -1));
 assertEquals(-1L, intent.getLongExtra("bar", -1));
}

代码示例来源:origin: TommyLemon/APIJSON

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.moment_list_activity, this);
  range = getIntent().getIntExtra(INTENT_RANGE, range);
  id = getIntent().getLongExtra(INTENT_ID, id);
  search = JSON.parseObject(getIntent().getStringExtra(INTENT_SEARCH));
  showSearch = getIntent().getBooleanExtra(INTENT_SHOW_SEARCH, showSearch);
  //功能归类分区方法,必须调用<<<<<<<<<<
  initView();
  initData();
  initEvent();
  //功能归类分区方法,必须调用>>>>>>>>>>
}

代码示例来源:origin: aa112901/remusic

@Override
protected String doInBackground(String... params) {
  if (getIntent().getParcelableArrayListExtra("ids") != null) {
    arrayList = getIntent().getParcelableArrayListExtra("ids");
    playlistId = getIntent().getLongExtra("playlistid", -1);
  }
  mAdapter = new SelectAdapter(arrayList);
  return "Executed";
}

代码示例来源:origin: TommyLemon/APIJSON

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.qrcode_activity, this);
  intent = getIntent();
  userId = intent.getLongExtra(INTENT_ID, userId);
  //功能归类分区方法,必须调用<<<<<<<<<<
  initView();
  initData();
  initEvent();
  //功能归类分区方法,必须调用>>>>>>>>>>
}

代码示例来源:origin: TommyLemon/Android-ZBLibrary

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.qrcode_activity, this);
  intent = getIntent();
  userId = intent.getLongExtra(INTENT_ID, userId);
  //功能归类分区方法,必须调用<<<<<<<<<<
  initView();
  initData();
  initEvent();
  //功能归类分区方法,必须调用>>>>>>>>>>
}

代码示例来源:origin: TommyLemon/Android-ZBLibrary

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  //TODO demo_activity改为你所需要的layout文件;传this是为了底部左右滑动手势
  setContentView(R.layout.demo_activity, this);
  intent = getIntent();
  userId = intent.getLongExtra(INTENT_USER_ID, userId);
  //功能归类分区方法,必须调用<<<<<<<<<<
  initView();
  initData();
  initEvent();
  //功能归类分区方法,必须调用>>>>>>>>>>
}

相关文章

Intent类方法