Blog Of Sem: February 2016

php gmail yolla

Önce gmailinde bu özelliği aktif et https://accounts.google.com/DisplayUnlockCaptcha

daha sonra burdan php maileri indir https://github.com/PHPMailer/PHPMailer/ ve ftpne at

mail yollamak php kodları aşağıdadır

<?php
date_default_timezone_set('America/Toronto');
require 'PHPMailerAutoload.php';
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$body             = "gdssdh";
//$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "ssl://smtp.gmail.com"; // SMTP server
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
$mail->Username   = "sender@gmail.com";  // GMAIL username
$mail->Password   = "senderpass";            // GMAIL password

$mail->SetFrom('receiver@gmail.com', 'PRSPS');

//$mail->AddReplyTo("receiver2@gmail.com', 'First Last");

$mail->Subject    = "PRSPS password";

//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "receiver@gmail.com";
$mail->AddAddress($address, "user2");

//$mail->AddAttachment("images/phpmailer.gif");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

android studio shared preferences

Define some statics to store the preference file name and the keys you're going to use:
public static final String PREFS_NAME = "MyPrefsFile";
private static final String PREF_USERNAME = "username";
private static final String PREF_PASSWORD = "password";
You'd then save the username and password as follows:
getSharedPreferences(PREFS_NAME,MODE_PRIVATE)
        .edit()
        .putString(PREF_USERNAME, username)
        .putString(PREF_PASSWORD, password)
        .commit();
So you would retrieve them like this:
SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);   
String username = pref.getString(PREF_USERNAME, null);
String password = pref.getString(PREF_PASSWORD, null);

if (username == null || password == null) {
    //Prompt for username and password
}
Alternatively, if you don't want to name a preferences file you can just use the default:
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);

android studio sdk 23den sdk 22 ye düşür httpclient için

android studio sdk 23den sdk 22 ye düşür httpclient için çünkü çoğu net dokumanı httpclient üzerinden gider.

Android studio file->settings->Android 5.1.1 seç ve android 6yı sil ok bas.SOnra file close ve proje oluştur.

android studio php json tips

android studioda php kullanırken notepad++da encoding in utf-8 olması gerekir bomsuz olması gerekir.
phpde jsonda dönen degerde turkce karakter hatalıysa

<?php
header('Content-Type: text/html; charset=utf-8');
require_once("baglan.php");//database bağlantısı gercekleştirdik
.............

....

echo utf8_encode(json_encode($cevap));// json verisini yazdırdık
}else{
echo "Giriş Engellendi";
}
?>



android studio mute unmute

private void mute() {
    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, true);
}

public void unmute() {
      AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
      am.setStreamMute(AudioManager.STREAM_MUSIC, false);
    }

httpclient and HttpURLConnection

                    HttpClient httpclient = new DefaultHttpClient();
                    HttpPost httppost = new HttpPost("http://192.168.43.94/spinner.php");
                    HttpResponse response = httpclient.execute(httppost);
                    is = entity.getContent();
                    Log.e("Fail 1", "3");



--------------------------------





                    URL url = new URL("http://192.168.43.94/spinner.php");
                    urlConnection = (HttpURLConnection) url.openConnection();
                    urlConnection.connect();
                    is = urlConnection.getInputStream();

apk inspector

İnstalling firstt 
Windows:
  1. Download Windows wrapper script (Right click, Save Link As apktool.bat)
  2. Download apktool-2 (find newest here)
  3. Rename downloaded jar to apktool.jar
  4. Move both files (apktool.jar & apktool.bat) to your Windows directory (Usually C://Windows)
  5. If you do not have access to C://Windows, you may place the two files anywhere then add that directory to your Environment Variables System PATH variable.
  6. Try running apktool via command prompt

then put in same directory the apk u want to decompile and
run cmd and go to directory a.apk
and apktool if a.apk
and apktool d a.apk d:\a\decompiledapk

ANDROID STUDIO ARRAY LIST

public class RemindersActivity extends ActionBarActivity {
private ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reminders);
mListView = (ListView) findViewById(R.id.reminders_list_view);
//The arrayAdatper is the controller in our
//model-view-controller relationship. (controller)
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
//context
this,
//layout (view)
R.layout.reminders_row,
//row (view)
R.id.row_text,
//data (model) with bogus data to test our listview
new String[]{"first record", "second record", "third record"});
mListView.setAdapter(arrayAdapter);
}
//

php basit geo ip

<?php
header('Content-Type: text/html; charset=utf-8');

$ip = @$_REQUEST['REMOTE_ADDR']; // the IP address to query
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));

echo $query['city'];
?>

android studio valuesda xml dosyasından spinnere alma

once valuesa sağ tıkla ve new xml value adınıda gunler koy
içinde :
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="gunler">
        <item>Pazartesi</item>
        <item>Salı</item>
        <item>Çarşamba</item>
        <item>Perşembe</item>
        <item>Cuma</item>
        <item>Cumartesi</item>
        <item>Pazar</item>
    </string-array>

</resources>

layout: activity_maine 1 adet spinner1 isminde spiner yarat
. java : MainActivity


package com.abysamltd.myapplication;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;


public class Main_Activity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //Spinner spinner = (Spinner) findViewById(R.id.spinner);
        android.widget.Spinner spinner = (android.widget.Spinner) findViewById(R.id.spinner1);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.gunler, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);


        spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
    }
    public class MyOnItemSelectedListener implements AdapterView.OnItemSelectedListener {

        public void onItemSelected(AdapterView<?> parent,
                                   View view, int pos, long id) {
            Toast.makeText(parent.getContext(), "Seçilen gün " +
                    parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
        }

        public void onNothingSelected(AdapterView parent) {
            // Do nothing.
        }
    }
}

add volley to android studio

Just include it in your gradle dependencies:
gradle script/ build gradle module

dependencies {
    ...
    compile 'com.mcxiaoke.volley:library:1.0.17'
}

Android Studio button switch use and one line goto intent activity

package com.abysamltd.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button b_kaydol_screen,b_giris_screen ;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        b_kaydol_screen = (Button) findViewById(R.id.b_kaydol_screen);
        b_giris_screen = (Button) findViewById(R.id.b_giris_screen);

        b_kaydol_screen.setOnClickListener(this);
        b_giris_screen.setOnClickListener(this);


    }
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.b_kaydol_screen:
            startActivity(new Intent(MainActivity.this, Activity_register.class));
            break;

            case R.id.b_giris_screen:
                startActivity(new Intent(MainActivity.this, Activity_login.class));
                break;


        }



    }

}