Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android OutofMemory崩溃“;无法使用可用字节分配字节分配_Android_Sqlite_Android Sqlite - Fatal编程技术网

Android OutofMemory崩溃“;无法使用可用字节分配字节分配

Android OutofMemory崩溃“;无法使用可用字节分配字节分配,android,sqlite,android-sqlite,Android,Sqlite,Android Sqlite,我不确定会发生什么我的记忆屏幕似乎会跳到大约100Mbs我不确定这是相当大的一点还是很正常。无论哪种方式,任何帮助都将是巨大的 03-03 13:37:43.229 133-133/? E/[EGL-ERROR]: egl_image* _egl_create_image_ANDROID_native_buffer(egl_display*, egl_context*, EGLClientBuffer, EGLint*, void*):593: CHUN try create image wit

我不确定会发生什么我的记忆屏幕似乎会跳到大约100Mbs我不确定这是相当大的一点还是很正常。无论哪种方式,任何帮助都将是巨大的

03-03 13:37:43.229 133-133/? E/[EGL-ERROR]: egl_image* _egl_create_image_ANDROID_native_buffer(egl_display*, egl_context*, EGLClientBuffer, EGLint*, void*):593: CHUN try create image with crop 0,0,0,0
03-03 13:37:43.553 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 447(20KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 4MB/4MB, paused 25.913ms total 87.278ms
03-03 13:37:43.656 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 46.371ms
03-03 13:37:43.726 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 936(110KB) AllocSpace objects, 0(0B) LOS objects, 36% free, 6MB/10MB, paused 49.983ms total 169.228ms
03-03 13:37:44.172 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 12MB/12MB, paused 115.409ms total 371.940ms
03-03 13:37:44.708 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 12.347ms
03-03 13:37:44.716 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 14(448B) AllocSpace objects, 0(0B) LOS objects, 19% free, 17MB/21MB, paused 157.012ms total 529.711ms
03-03 13:37:44.966 154-154/? D/AudioMTKHardware: +setParameters(): rotation=90 
03-03 13:37:44.966 154-154/? D/AudioMTKHardware: +setCommonParameters(): rotation=90 
03-03 13:37:44.966 154-154/? D/AudioMTKHardware: Remove key rotation from pair rotation=90
03-03 13:37:44.967 154-154/? D/AudioMTKHardware: -setCommonParameters(): rotation=90 
03-03 13:37:44.967 154-154/? E/audio_a2dp_hw: adev_set_parameters: ERROR: set param called even when stream out is null
03-03 13:37:45.486 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 360.502ms
03-03 13:37:45.496 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 4(128B) AllocSpace objects, 0(0B) LOS objects, 0% free, 22MB/22MB, paused 215.163ms total 697.293ms
03-03 13:37:46.297 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 666.999ms
03-03 13:37:46.307 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 10(320B) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 216.105ms total 790.569ms
03-03 13:37:46.671 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 37.559ms
03-03 13:37:47.295 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 8(256B) AllocSpace objects, 0(0B) LOS objects, 0% free, 28MB/28MB, paused 281.801ms total 881.029ms
03-03 13:37:48.333 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 693.489ms
03-03 13:37:48.350 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 14(448B) AllocSpace objects, 0(0B) LOS objects, 12% free, 28MB/32MB, paused 280.007ms total 1.040s
03-03 13:37:48.797 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 445.971ms
03-03 13:37:48.811 18779-18794/edu.byu.cs.superasteroids W/art: Suspending all threads took: 460.896ms
03-03 13:37:48.824 18779-18779/edu.byu.cs.superasteroids D/AndroidRuntime: Shutting down VM
03-03 13:37:49.374 456-521/? E/WifiStateMachine: stopReconnectWifi Wfd=false StopScan=false mDontReconnectAndScan=false
03-03 13:37:50.037 1170-1170/? I/wpa_supplicant: wlan0: CTRL-EVENT-SCAN-RESULTS 
03-03 13:37:50.868 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 1.714s
03-03 13:37:51.046 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 139.310ms
03-03 13:37:51.122 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 38.308ms
03-03 13:37:51.160 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 4947(178KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/95MB, paused 2.320ms total 2.261s
03-03 13:37:51.160 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 596.300ms for cause Alloc
03-03 13:37:51.372 133-206/? I/hwcomposer: [DPY] UEventThread::threadLoop recv change@/devices/platform/battery/power_supply/battery
03-03 13:37:51.611 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 742407(26MB) AllocSpace objects, 0(0B) LOS objects, 5% free, 69MB/73MB, paused 1.030ms total 336.375ms
03-03 13:37:51.611 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 332.947ms for cause Alloc
03-03 13:37:51.706 18779-18794/edu.byu.cs.superasteroids W/art: Suspending all threads took: 93.970ms
03-03 13:37:51.894 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 18810(2MB) AllocSpace objects, 9(1698KB) LOS objects, 0% free, 77MB/77MB, paused 1.393ms total 133.657ms
03-03 13:37:52.143 456-667/? I/ActivityManager: Killing 18668:jp.co.omronsoft.iwnnime.mlaz/u0a13 (adj 12): empty #13
03-03 13:37:52.176 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 73610(8MB) AllocSpace objects, 4(5MB) LOS objects, 4% free, 81MB/85MB, paused 1.165ms total 252.249ms
03-03 13:37:52.176 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 55.036ms for cause Alloc
03-03 13:37:52.176 18779-18789/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 17.252ms for cause Alloc
03-03 13:37:52.513 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 47138(5MB) AllocSpace objects, 3(6MB) LOS objects, 4% free, 81MB/85MB, paused 886us total 220.420ms
03-03 13:37:52.514 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 116.996ms for cause Alloc
03-03 13:37:52.804 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 145.094ms
03-03 13:37:52.847 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 30235(3MB) AllocSpace objects, 1(6MB) LOS objects, 4% free, 85MB/89MB, paused 1.190ms total 255.264ms
03-03 13:37:52.972 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 16.783ms for cause Alloc
03-03 13:37:53.009 18779-18779/edu.byu.cs.superasteroids I/art: Alloc sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 2% free, 84MB/86MB, paused 1.120ms total 8.917ms
03-03 13:37:53.254 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 93.605ms
03-03 13:37:53.282 18779-18779/edu.byu.cs.superasteroids I/art: Alloc partial concurrent mark sweep GC freed 17(912B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.108ms total 218.701ms
03-03 13:37:53.527 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 13(12KB) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.015ms total 216.641ms
03-03 13:37:53.554 18779-18779/edu.byu.cs.superasteroids I/art: Forcing collection of SoftReferences for 14MB allocation
03-03 13:37:53.770 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 105.509ms
03-03 13:37:53.797 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 11(344B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.051ms total 216.460ms
03-03 13:37:53.824 18779-18779/edu.byu.cs.superasteroids E/art: Throwing OutOfMemoryError "Failed to allocate a 15587580 byte allocation with 4194304 free bytes and 11MB until OOM"
03-03 13:37:53.834 18779-18779/edu.byu.cs.superasteroids I/art: Alloc sticky concurrent mark sweep GC freed 5(448B) AllocSpace objects, 0(0B) LOS objects, 2% free, 84MB/86MB, paused 1.066ms total 8.626ms
03-03 13:37:54.078 18779-18779/edu.byu.cs.superasteroids I/art: Alloc partial concurrent mark sweep GC freed 10(320B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.130ms total 215.957ms
03-03 13:37:54.320 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 151.859ms
03-03 13:37:54.347 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.031ms total 214.426ms
03-03 13:37:54.374 18779-18779/edu.byu.cs.superasteroids I/art: Forcing collection of SoftReferences for 14MB allocation
03-03 13:37:54.589 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 7(224B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 894us total 214.533ms
03-03 13:37:55.554 18779-18779/edu.byu.cs.superasteroids E/art: Throwing OutOfMemoryError "Failed to allocate a 15587580 byte allocation with 4194304 free bytes and 11MB until OOM"
03-03 13:37:55.611 18779-18779/edu.byu.cs.superasteroids E/AndroidRuntime: Error reporting crash, early in start. Won't generate crash log file.
                                                                           java.lang.OutOfMemoryError: Failed to allocate a 15587580 byte allocation with 4194304 free bytes and 11MB until OOM
                                                                               at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
                                                                               at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:125)
                                                                               at java.lang.StringBuffer.append(StringBuffer.java:278)
                                                                               at java.io.StringWriter.write(StringWriter.java:123)
                                                                               at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:358)
                                                                               at com.android.internal.util.FastPrintWriter.appendLocked(FastPrintWriter.java:303)
                                                                               at com.android.internal.util.FastPrintWriter.write(FastPrintWriter.java:625)
                                                                               at com.android.internal.util.FastPrintWriter.append(FastPrintWriter.java:658)
                                                                               at java.io.PrintWriter.append(PrintWriter.java:691)
                                                                               at java.io.PrintWriter.append(PrintWriter.java:31)
                                                                               at java.lang.Throwable.printStackTrace(Throwable.java:323)
                                                                               at java.lang.Throwable.printStackTrace(Throwable.java:300)
                                                                               at android.util.Log.getStackTraceString(Log.java:340)
                                                                               at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:59)
                                                                               at com.android.internal.os.RuntimeInit.access$200(RuntimeInit.java:43)
                                                                               at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:85)
                                                                               at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                                                                               at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
}

美国超甾体类药物进口商提供的包装;
导入android.content.res.AssetManager;
导入android.content.res.Resources;
导入android.os.Bundle;
导入android.support.v4.app.Fragment;
导入android.support.v7.app.ActionBarActivity;
导入android.view.LayoutInflater;
导入android.view.Menu;
导入android.view.MenuItem;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.AdapterView;
导入android.widget.ListView;
导入android.widget.Toast;
导入java.io.BufferedInputStream;
导入java.io.IOException;
导入java.io.InputStreamReader;
导入java.util.ArrayList;
导入java.util.List;
进口超甾体类药物;
公共类导入扩展了ActionBarActivity{
私有列表视图列表视图;
私人资源;
私人资产管理人am;
私有列表文件列表;
私人IGAMEDATA进口商数据进口商;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u导入);
如果(savedInstanceState==null){
getSupportFragmentManager().beginTransaction()
.add(R.id.container,新的占位符片段())
.commit();
}
//TODO:将数据导入器设置为GameDataImporter的实例
数据导入器=新游戏数据导入器(此);
}
@凌驾
恢复时公开作废(){
super.onResume();
res=getResources();
am=res.getAssets();
String[]files=null;
试一试{
files=am.list(“”);
}捕获(IOE异常){
e、 printStackTrace();
}
fileList=null;
如果(文件!=null){
fileList=newarraylist();
用于(字符串文件:文件){
if(file.endsWith(“.json”))
fileList.add(文件);
}
如果(fileList.size()>0){
ImportFileAdapter fileAdapter=新的ImportFileAdapter(此,
android.R.layout.simple_list_item_1,fileList);
ListView ListView=(ListView)findViewById(R.id.import\u列表);
setAdapter(fileAdapter);
setOnItemClickListener(fileClickListener);
fileAdapter.notifyDataSetChanged();
}
}
}
私有AdapterView.OnItemClickListener文件ClickListener=new AdapterView.OnItemClickListener(){
@凌驾
公共无效onItemClick(AdapterView AdapterView、View视图、int i、long l){
Toast Toast=Toast.makeText(ImportActivity.this,“,Toast.LENGTH\u LONG);
if(dataImporter==null){
toast.setText(“导入程序尚未实现或创建…\n文件未导入”);
}
否则{
试一试{
布尔成功=dataImporter.importData(新的InputStreamReader(
新的BufferedInputStream(am.open(fileList.get(i '));
如果(成功)
setext(“文件已导入”);
其他的
setText(“导入程序尝试导入文件时出错。”);
}捕获(IOE异常){
e、 printStackTrace();
toast.setText(“无法导入该文件,因为它不存在。”);
}
}
toast.show();
}
};
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.menu\u导入,菜单);
返回true;
}
@凌驾
公共布尔值onOptionsItemSelected(菜单项项){
//处理操作栏项目单击此处。操作栏将
//自动处理Home/Up按钮上的点击,只要
//在AndroidManifest.xml中指定父活动时。
int id=item.getItemId();
//noinspection SimplifiableIf语句
if(id==R.id.action\u设置){
返回true;
}
返回super.onOptionsItemSelected(项目);
}
/**
*包含简单视图的占位符片段。
*/
公共静态类占位符片段扩展了片段{
公共占位符片段(){
}
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
视图根视图=充气机。充气(R.layout.fragment\u导入,容器,false);
返回rootView;
}
}
}


虽然我不确定这是否真的是崩溃的地方,但我这么说是因为这些代码部分现在工作得很好,有时只是打开应用程序需要大量数据,而它似乎不工作

你的代码在哪里崩溃?你用的是大图像吗?显示你的代码我可以从你的日志中预测到什么,你不断地旋转图片,那么你不重新链接位图吗?不管怎么说,如果没有看到你的代码伙计,我就不能说太多。
    package edu.byu.cs.superasteroids.main_menu;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import edu.byu.cs.superasteroids.R;
import edu.byu.cs.superasteroids.base.ActionBarActivityView;
import edu.byu.cs.superasteroids.content.ContentManager;
import edu.byu.cs.superasteroids.database.DBhelper;
import edu.byu.cs.superasteroids.game.GameActivity;
import edu.byu.cs.superasteroids.importer.ImportActivity;
import edu.byu.cs.superasteroids.ship_builder.ShipBuildingActivity;

public class MainActivity extends ActionBarActivityView implements IMainMenuView {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }

    //TODO: Set this activity's controller to an instance of your MainMenuController
    //TODO: Pass the MainMenuController's constructor a reference to its IMainMenuView (this)
    //IMainMenuController controller = new MainMenuController(this);
    //setController(controller);


    //TODO: Initialize your database

    DBhelper.init(getBaseContext());

    ContentManager.getInstance().setResources(getResources());
    ContentManager.getInstance().setAssets(getAssets());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container, false);
        return rootView;
    }
}

public void startGame(View v) {
    Intent intent = new Intent(this, ShipBuildingActivity.class);
    startActivity(intent);
}

public void quickPlay(View v) {
    if (getController() != null) {
        ((IMainMenuController) getController()).onQuickPlayPressed();
    }
}

public void startGame() {
    Intent intent = new Intent(this, GameActivity.class);
    intent.setFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP);
    this.startActivity(intent);
}

public void importData(View v) {
    Intent intent = new Intent(this, ImportActivity.class);
    startActivity(intent);
}


@Override
public void onDestroy() {
    super.onDestroy();
}
package edu.byu.cs.superasteroids.importer;

import android.content.res.AssetManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import edu.byu.cs.superasteroids.R;

public class ImportActivity extends ActionBarActivity {

private ListView listView;
private Resources res;
private AssetManager am;
private List<String> fileList;
private IGameDataImporter dataImporter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_import);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }

    //TODO: Set the dataimporter to an instance of your GameDataImporter
    dataImporter = new GameDataImporter(this);

}


@Override
public void onResume() {

    super.onResume();

    res = getResources();
    am = res.getAssets();

    String[] files = null;
    try {
        files = am.list("");
    } catch (IOException e) {
        e.printStackTrace();
    }

    fileList = null;
    if(files != null) {
        fileList = new ArrayList<String>();
        for(String file : files) {
            if(file.endsWith(".json"))
                fileList.add(file);
        }
        if(fileList.size() > 0) {
            ImportFileAdapter fileAdapter = new ImportFileAdapter(this,
                    android.R.layout.simple_list_item_1, fileList);
            ListView listView = (ListView) findViewById(R.id.import_list);
            listView.setAdapter(fileAdapter);
            listView.setOnItemClickListener(fileClickListener);
            fileAdapter.notifyDataSetChanged();
        }
    }

}

private AdapterView.OnItemClickListener fileClickListener = new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

        Toast toast = Toast.makeText(ImportActivity.this, "", Toast.LENGTH_LONG);
        if(dataImporter == null) {
            toast.setText("The importer has not been implemented or created yet...\nThe file was not imported.");
        }
        else {
            try {

                boolean success = dataImporter.importData(new InputStreamReader(
                        new BufferedInputStream(am.open(fileList.get(i)))));

                if (success)
                    toast.setText("The file was imported.");
                else
                    toast.setText("An error occurred as the importer tried to import the file.");

            } catch (IOException e) {
                e.printStackTrace();
                toast.setText("The file could not be imported, because it does not exist.");
            }
        }
        toast.show();
    }
};

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_import, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_import, container, false);
        return rootView;
    }
}