Uygulamanın çalışmadığı hatta hiç açılmadığı cihazlardan biri bu verdiği hata ne anlama geliyor acaba?
Android Kod Hatası! Bakar mısınız Lütfen |
14 Mesajlar | 2.555 Okunma |
package com.inddir.cesur.elfeneri;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageButton;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
public class ELFeneri extends AppCompatActivity {
private Camera camera;
private Camera.Parameters parameters;
private ImageButton btn;
boolean isFlashLightOn = false;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_elfeneri);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
btn = (ImageButton) findViewById(R.id.btn);
button = (Button) findViewById(R.id.button);
btn.setOnClickListener(new FlashOnOffListener());
if (isFlashSupported()) {
camera = Camera.open();
parameters = camera.getParameters();
} else {
showNoFlashAlert();
}
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog alertDialog = new AlertDialog.Builder(ELFeneri.this).create();
alertDialog.setTitle("inddir.com");
alertDialog.setMessage("2017 @ Her Hakkı Saklıdır.");
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
}
});
}
private class FlashOnOffListener implements View.OnClickListener{
@Override
public void onClick(View v) {
if(isFlashLightOn){
btn.setImageResource(R.drawable.kapali);
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
camera.stopPreview();
isFlashLightOn = false;
}else{
btn.setImageResource(R.drawable.acik);
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameters);
camera.startPreview();
isFlashLightOn = true;
}
}
}
private void showNoFlashAlert() {
new AlertDialog.Builder(this)
.setMessage("Cihaz Flaşı desteklemiyor!")
.setIcon(android.R.drawable.ic_dialog_alert).setTitle("Hata")
.setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
}).show();
}
private boolean isFlashSupported() {
PackageManager pm = getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
}
@Override
protected void onDestroy() {
if(camera != null){
camera.stopPreview();
camera.release();
camera = null;
}
super.onDestroy();
}
}
package="com.inddir.cesur.elfeneri">
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
android:screenOrientation="portrait">