我在Android中使用相机,我是Android相机的新手.我从这里开始关注教程
每当我在android清单中添加外部存储权限时,相机会将其保存在默认目录中,而不会询问我,我想将其保存在我在sd卡中创建的文件夹中.我搜索了很多但找不到任何有用的链接.请帮助,任何帮助将不胜感激.谢谢 :)
我正试图通过意图播放存储在android内存中的视频文件.文件存在那里,但当我尝试通过意图播放它时,它会给我错误"媒体文件不支持"或"无法播放视频",具体取决于设备.我找不到我错的地方.这是我的代码
File mydir = activity.getDir("Videos", Context.MODE_PRIVATE);
File fileWithinMyDir = new File(mydir, filename);
String videoResource = fileWithinMyDir.getPath();
Uri intentUri = Uri.parse(videoResource);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(intentUri, "video/mp4");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我不知道我哪里错了,我该怎么办.任何帮助将非常感激.谢谢 :)
我正在尝试制作圆形的表面视图.我搜索了很多,但我找不到一个好的解决方案.我现在正在做的是,我将SurfaceView放入FrameLayout,然后将另一个View放在它上面,或者使用PNG蒙版,或者使用形状xml drawable.这里是
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#000"
android:orientation="vertical"
android:visibility="visible" >
<FrameLayout
android:id="@+id/videorecordview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight=".2" >
<SurfaceView
android:id="@+id/surfaceView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/rounded"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但这不是一个好的解决方案,也不是完美的.我想将surfaceview自定义为圆形.任何帮助将非常感激.谢谢 :)
我正在解析一个json字符串.当我运行我的代码时,我收到json异常,在从json对象获取json数组的点处显示"类型不匹配".这是我的代码
String dataFromLogin="{"catego":{"id":"2","fname":"Tashen Jazbi","uname":"tashen",
"password":"123","pic_url":"","lati":"33.7167","longi":"73.0667","city":"Islamabad",
"country":"Pakistan","mobid":"000000000000000","street":"xyz",
"dateandtime":"2013-12-29 18:07:52"}}";
try {
JSONObject jsonObj = new JSONObject(dataFromLogin);
//JSONObject response = jsonObj.getJSONObject("catego");
JSONArray contacts = jsonObj.getJSONArray("catego");
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
fullname = c.getString("fname");
uname = c.getString("uname");
pic_url = c.getString("pic_url");
lat = c.getString("lati");
lng = c.getString("longi");
city = c.getString("city");
country = c.getString("country");
street= c.getString("street");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我找不到哪里做错了.如果有人可以提供帮助,那么我们将非常感激.
谢谢 :)