小编Jia*_*ang的帖子

错误:打开失败:ENOENT(没有这样的文件或目录)

我试图创建一个文件来保存相机中的图片,事实证明我无法创建该文件.但我真的找不到错误.你能看看它并给我一些建议吗?

private File createImageFile(){
        File imageFile=null;
        String stamp=new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        File dir= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
        String imageFileName="JPEG_"+stamp+"_";
        try {
            imageFile=File.createTempFile(imageFileName,".jpg",dir);
        } catch (IOException e) {
            Log.d("YJW",e.getMessage());
        }
        return  imageFile;
    }
Run Code Online (Sandbox Code Playgroud)

我已经添加了许可.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Run Code Online (Sandbox Code Playgroud)

该方法总是会出现这样的错误:

打开失败:ENOENT(没有这样的文件或目录)

android

30
推荐指数
5
解决办法
6万
查看次数

无法识别启动活动:未找到默认活动

我是android的新手,我遇到了一个问题.控制台说"无法识别启动活动:未找到默认活动".我补充说

<intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

在清单中.我已经尝试过Invalidate caches/Restart,但仍然无效.并且包含主要活动的类文件在android studio中变为绿色.我不知道这意味着什么.这是我的清单文件.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mrrobot.mycoolweather" >
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <Activity       android:name="com.example.mrrobot.mycoolweather.activity.ChooseAreaActivity"
        android:label="@string/app_name">
        <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)

chooseAreaActivity是我想用作启动器活动的那个. 在此输入图像描述

android android-manifest

16
推荐指数
5
解决办法
6万
查看次数

Fragment.getView()始终返回null

我在MainActivity中动态地向ViewPager中添加了两个片段,而我试图获取片段的子视图,Fragment.getView()总是返回null,如何解决这个问题?提前致谢。

mLinearLayout= (LinearLayout)fragments.get(0).getView().findViewById(R.id.linear_layout);
    mRelativeLayout= (RelativeLayout) fragments.get(1).getView().findViewById(R.id.relative_layout);
Run Code Online (Sandbox Code Playgroud)

android android-fragments

1
推荐指数
1
解决办法
1734
查看次数