最後に解決策を得ました。
ログファイルを生成するカスタムプラグインからカスタムアプリケーションクラスを追加しました。
マニフェスト入力の場合は、すべての作業を行うためのplugin.xmlを変更します。私はApplicationクラス怒鳴るを作成
、
public class CustomApplication extends Application{
private static final String TAG = "CustomApplication";
/**
* Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created.
*/
public void onCreate()
{
Log.e(TAG, "from onCreate");
super.onCreate();
if (isExternalStorageWritable())
{
Log.e(TAG,"file path : " + this.getExternalFilesDir(null).getPath() + "/MyApp");
File appDirectory = new File(this.getExternalFilesDir(null).getPath() + "/MyApp");
File logDirectory = new File(appDirectory + "/log");
File logFile = new File(logDirectory, "logcat" + ".txt");
// create app folder
if (!appDirectory.exists())
{
appDirectory.mkdir();
}
// create log folder
if (!logDirectory.exists())
{
logDirectory.mkdir();
}
// clear the previous logcat and then write the new one to the file
try
{
Process process = Runtime.getRuntime().exec("logcat -c");
process = Runtime.getRuntime().exec("logcat -f " + logFile);
} catch (IOException e)
{
e.printStackTrace();
}
} else if (isExternalStorageReadable())
{
Log.e(TAG,"only readable external storage");
// only readable
} else
{
Log.e(TAG,"not accessible external storage");
// not accessible
}
}
/* Checks if external storage is available for read and write */
public boolean isExternalStorageWritable()
{
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
return false;
}
/* Checks if external storage is available to at least read */
public boolean isExternalStorageReadable()
{
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
return true;
}
return false;
}
}
以下のようにアプリケーションの
コルドバプラグインのplugin.xmlファイルの変更、
<source-file src="src/android/CustomApplication.java" target-dir="src/com/MyApplication" />
<edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
<application android:name="CustomApplication"/>
</edit-config>