我试图在一个非常简单的应用程序(一个只有谷歌地图活动的新项目)中显示谷歌地图,清单具有以下权限:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ivan.pruebamaps">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我在@ string/google_maps_key中有一个有效的密钥.
它没有触及mainActivity,就像它在android studio中创建的一样.
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this); …Run Code Online (Sandbox Code Playgroud) 我在片段中加载谷歌地图时遇到问题.一切都从一个启动活动"ViatgeDetallViewActivity"的回收器视图适配器开始:
Context context = mActivity.getApplicationContext();
Intent intent = new Intent(context, ViatgeDetallViewActivity.class);
holder.mViatge.getId());
intent.putExtra("desc",p.getDesc());
intent.putExtra("location",p.getLocation());
mActivity.startActivityForResult(intent,ACTIVITY_View);
Run Code Online (Sandbox Code Playgroud)
这是我的DetallViewActivity:
public class ViatgeDetallViewActivity extends AppCompatActivity {
ViatgeDetallViewFragment fragment;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);
Bundle extras = getIntent().getExtras();
if(extras != null)
{
String s = getIntent().getStringExtra("desc");
Location l = getIntent().getParcelableExtra("location");
Log.d("myTag", "estoy en el oncreate de detallviewActivity pasando pro extras" + s );
}
fragment = new ViatgeDetallViewFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.activity_fragment_view, fragment)
.commit();
getFragmentManager().beginTransaction().add(R.id.activity_fragment_view, fragment).commit();
}
}
Run Code Online (Sandbox Code Playgroud)
我的ViatgeDetallViewFragment是:
public class ViatgeDetallViewFragment extends Fragment implements …Run Code Online (Sandbox Code Playgroud) 我正在用指令启动一个进程
execl("./softCopia","softCopia",NULL);
Run Code Online (Sandbox Code Playgroud)
softCopia只是一个在文件中写入整数的虚拟对象.
我想知道如何获得这个过程的pid?
我正在尝试在 android studio 中解析一个包含以下内容的 JSON:
"stops":
[
{
"num": 1,
"time": "2016-04-27T06:15:00.000Z",
"title":"Flight to London",
"desc":"Barcelona BCN-London-Gatwick LGW",
"type":"0",
"subtype":0
},
{
"num": 2,
"time": "2016-04-27T10:35:00.000Z",
"title":"Gatwick express",
"desc":"From Airport to London",
"type":"0",
"subtype":1
},
{
"num": 3,
"time": "2016-04-27T12:15:00.000Z",
"title":"Pub the black horse",
"desc":"From Airport to London",
"type":1,
"subtype":1,
"location": "51.476334, -0.062700",
"images": [ "https://fitzrovianews.files.wordpress.com/2011/01/black_horse_rathbone_pl.jpg"
]
},
{
"num": 4,
"time": "2016-04-27T12:16:47.000Z",
"title":"The Tower Bridge",
"desc":"# The Tower Bridge Facts\n## Architecture\n**Tower Bridge** is a combined bascule and suspension bridge …Run Code Online (Sandbox Code Playgroud) 我正在使用netbeans,我创建了这个异常类:
public class VehicleException extends Exception{
private String matricula;
private Calendar dataMatricula;
private ModelVehicle model;
private int causa;
public VehicleException(int causa, Object valor) throws Exception {
this.causa = causa;
switch (causa) {
case 1:
dataMatricula = (Calendar) valor;
break;
case 2:
matricula = (String) valor;
break;
case 3:
model = (ModelVehicle) valor;
break;
default:
throw new Exception("Utilització errònia en construir VehicleException. Causa: " + causa);
}
}
@Override
public String getMessage() {
switch (causa) {
case 1:
return "dataMatricula erroni: …Run Code Online (Sandbox Code Playgroud)