如果我在'Gemfile'中编写以下代码:
group :development do
gem 'xyz'
end
group:test do
gem 'xyz'
end
Run Code Online (Sandbox Code Playgroud)
那是什么意思?
谢谢.
我将值传递给另一个活动,但始终为null值
public class SatelliteDirectActivity extends Activity {
private Intent intent;
private Bundle b;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
intent = new Intent(SatelliteDirectActivity.this,ClsMainActivitySatelliteDirect.class);
b = new Bundle();
setContentView(R.layout.initial_splash_screen);
boolean bCheckInternetConnectivity = checkInternetConnection();
if(!bCheckInternetConnectivity)
{
Toast.makeText(this, "Please ensure that you have a internet connectivity", Toast.LENGTH_SHORT);
finish();
}
else
{
new GetCountryInformation().execute();
}
startActivity(intent);
finish();
}
private boolean checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != …Run Code Online (Sandbox Code Playgroud) 在我正在处理的应用程序中,我有一个ListView的第一个活动,它从保存到apps内部存储器的ArrayList填充.无论是通过菜单按钮,选择"添加"或在菜单中攻现有项目我能到这是一个编辑页面我的第二次活动.
在第一个活动中,如果按下"添加"按钮,则意图中没有传递额外内容,并且编辑活动中不需要填充任何字段(文本框等).如果在第一个活动中单击现有项目,则会将该项目的行ID作为额外内容传递给Intent,其中键字符串为"_id".
我知道*Bundle.getLong("_ id");*如果没有与intent一起传递额外的话,应返回null.我的问题是,由于某种原因,getLong()总是返回0.我尝试将一些乱码作为getLong()的关键字符串,但它仍然返回0.有没有人遇到过这个问题?
我还想补充一点,我还有两组与此类似的活动,使用相同的方法获取rowId(如果已经通过),它们都可以正常工作.
我找不到任何可能导致此问题的常见问题.在此先感谢您的帮助.
[编辑]
对任何令人困惑的事情表示歉意,并且之前未显示此代码.正如一些人评论说,如果getLong找不到任何东西,它将返回0,但是我使用的代码将mRowId设置为null,如果是这种情况,或者至少我认为它确实如此.这有点让我困惑,但似乎没有其他额外的意图传递.
mRowId = extras != null
? extras.getLong("_id")
: null;
Run Code Online (Sandbox Code Playgroud)
我也有另一个烂摊子四周,发现如果任何额外的价值与目的(无论其键),通过它,则它会返回0,而不是空.我假设如果传递了另一个额外的代码,则此代码不起作用.如果是这种情况,有必要在更好的方法传递rowId,如果没有传递则将其设置为null.
有没有办法将捆绑注入服务?
我想写这样的服务构造函数:
<?php
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MyService
{
/** @var Bundle */
private $bundle;
public function __construct(Bundle $bundle)
{
$this->bundle = $bundle;
}
}
Run Code Online (Sandbox Code Playgroud)
因为services.yml我想要这样的东西:
services:
my_service:
class: MyService
arguments: ['how_can_i_reference_a_bundle']
Run Code Online (Sandbox Code Playgroud) 如果可以将SpannableString设置为片段的参数,怎么办?
Bundle args = new Bundle();
args.putString(PagesFragment.ARG_SECTION_NUMBER, Page[position]);
fragment.setArguments(args);
return fragment;
Run Code Online (Sandbox Code Playgroud)
在此示例代码中需要更改什么?
将应用程序上载到appStore时,Apple会检查捆绑软件版本是否高于现有版本。我自己有这样做的现有方法吗?我正在通过企业版程序发布应用程序,并且内置了一种机制来检查URL的较新版本。目前我只用
if (![currentVersion isEqualToString:onlineVersion])
Run Code Online (Sandbox Code Playgroud)
但这太粗糙了,因为如果有旧版本,它也会返回TRUE。
现在,意识到1.23.0> 1.3.0,我必须将组件中的版本分开,然后将每个本地组件与其相关的在线组件进行比较。
如果我必须这样做,那么我必须这样做,但是我认为这是一个捷径。
任何人?
我正在创建一个动态表单活动,我得到了如何从db创建表单的说明.活动基本上只是滚动问题列表并查看它们的类型并添加它们.所以这是一个将视图添加为问题的活动.这一切都很好.我试图将响应/问题保留在特定问题类中,这些类只是一个基本问题的子类.
我遇到的问题是当我尝试添加相机"问题"以提示用户拍照时,我无法在视图中获得结果.我在视图中管理了启动活动,并将结果返回到问卷调查活动.活动不知道将其添加到哪个问题,因为它都是动态完成的.因此,我尝试通过问题ID作为相机意图中的额外内容,并在问卷调查活动中接收它,然后滚动查看它添加的问题,如果它是相同的,它会将图片添加到与之关联的问题中.
它添加问题的方式是通过一个视图组,只为每个视图组插入一个部分.
这是启动相机的相关部分(我也试过使用它而没有捆绑).这是BaseQuestion的子类,它只是linearlayout的子类:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Bundle bundle = new Bundle();
bundle.putInt("questionId", getQuestionId());
intent.putExtras(bundle);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(
Environment.getExternalStorageDirectory(), "image.tmp")));
((Activity)getContext()).startActivityForResult(intent, TAKE_PHOTO);
Run Code Online (Sandbox Code Playgroud)
这是处理活动中结果的相关部分.
protected void onActivityResult(int requestCode, int resultCode,
Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
Bitmap image = null;
switch (requestCode)
{
case TAKE_PHOTO:
{
if (resultCode == RESULT_OK)
{
InputStream inputStream = null;
File file = new File(Environment.getExternalStorageDirectory(),
"image.tmp");
try {
inputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if (inputStream == …Run Code Online (Sandbox Code Playgroud) 我有使用Google地图的活动,这是点击标记的代码.正如您所看到的,它使用参数启动第二个活动:
public void onInfoWindowClick(Marker marker) {
SQLiteDatabase dbRead = db.getReadableDatabase();
String[] columns = {"_id", "title", "addr"};
Cursor result = dbRead.query("merchants", columns, null, null, null, null, null);
long id = 0;
while(result.moveToNext()) {
if (marker.getTitle().equals(result.getString(1)) && marker.getSnippet().equals(result.getString(2))) {
id = result.getLong(0);
}
}
Intent intent = new Intent(this, ViewMerchant.class);
Bundle b = new Bundle();
b.putInt("id", (int)id);
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
这是第二个活动代码的一部分:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.viewmerchant);
Bundle b = getIntent().getExtras();
int id = b.getInt("id");
...
}
Run Code Online (Sandbox Code Playgroud)
这是LogCat:
05-18 19:05:34.785: D/AndroidRuntime(28444): Shutting …Run Code Online (Sandbox Code Playgroud) parameters android bundle nullpointerexception android-intent
在传递到Android上的片段之前,是否可以将两个捆绑包合并为一个?所以代码片段类似于:
Bundle b1 = SomeClass1.getSomeBundle();
Bundle b2 = SomeClass2.getDifferentBundle();
// How to do I pass these two bundles to a fragment?
fragment.setArgument(b1 + b2); // Illustrative only.
Run Code Online (Sandbox Code Playgroud) 在片段里面 onCreateView
putExtra(dataBundle);
Run Code Online (Sandbox Code Playgroud)
给
无法解决方法'putExtra(android.os.bundle)'错误
但
putExtra("id", id_To_Search);
Run Code Online (Sandbox Code Playgroud)
工作良好.我想发送dataBunle指导我,我错过了什么.
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
int id_To_Search = position + 1;
Bundle dataBundle = new Bundle();
dataBundle.putInt("id", id_To_Search);
Intent intent = new Intent(getActivity(), DetailActivity.class).putExtra(dataBundle);
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)