Archive for April 2018
<?php
$zip = new ApkArchive;
$file = $zip->open("tes.zip");
if ($file === TRUE) {
$zip->extractTo("hasil-unzip");
$zip->close(); // tutup
echo "Berhasil!";
}
else
{
echo "Gagal";
}
?>
[WEB] Extrack Zip
Buat folder terlebih dahulu didalam public_html sebagai penyimpanan file
Untuk menyimpan file jenis lain kita tinggal mengganti extensi file di script php dibawah
Index.html
<!DOCTYPE html>
<html>
<body>
<form action="proses.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="UploadFile" id="UploadFile">
<input type="submit" value="Upload Gambar" name="submit">
</form>
</body>
</html>
proses.php
<?php
$var = "video/";
$folder =$var.basename($_FILES["UploadFile"]["name"]);
$FileType = pathinfo($folder,PATHINFO_EXTENSION);
if ($_FILES["UploadFile"]["size"] >9999999999999999){
echo "Maaf, ukuran file terlalu besar.";}
if($FileType != "mp4" &&
$FileType != "mkv" &&
$FileType != "3gp" &&
$FileType != "avi"){
echo "extensi file tidak di dukung";}else{ move_uploaded_file($_FILES["UploadFile"]["tmp_name"], $folder);}?>
[WEB] upload file to server
Nb:
untuk bisa berpindah anda harus mengetahui nama package aplikasi target dan activitynya
Seperti contoh di bawah
com.melki adalah package
Dan MainActivity adalah Activitynya
Tapi disini activitynya ditulis package + activity =com.melki.MainActivity
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.btn);
btn.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v){
Intent ii=new Intent();
ii.setComponent(new ComponentName("com.melki","com.melki.MainActivity"));
try{
startActivity(ii);
}catch(Exception e)
{
Toast.makeText(MainActivity.this,"aplikasi tidak terinstal",Toast.LENGTH_SHORT).show();}};});}}
[DROID] Berpindah Aplikasi (implicit)
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
import android.content.*;
import android.net.*;
public class MainActivity extends Activity implements View.OnClickListener {
EditText edit;
Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button= (Button) findViewById(R.id.btn);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"whatsappsharing",Toast.LENGTH_SHORT).show();
Intent whatsappintent=new Intent();
whatsappintent.setAction(Intent.ACTION_SEND);
whatsappintent.setType("text/plain");
whatsappintent.putExtra(Intent.EXTRA_TEXT, "testing programing");
whatsappintent.setPackage("com.whatsapp");
startActivity(whatsappintent);
}}
[DROID] Mengirim text Ke Whatsapp (implicit Intent)
Nn: jika iklan tidak tampil maka ganti nama package menggunakan apk editor
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/t"
android:text="wait"/>
</LinearLayout>
MainActivity.java
package com.mycompany.myapp;
import android.app.*;
import android.os.*;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.AdListener;
import android.util.*;
import android.widget.*;
public class MainActivity extends Activity
{
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-8053190329240173/4842633610");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {}
@Override
public void onAdFailedToLoad(int errorCode) {}
@Override
public void onAdOpened() {}
@Override
public void onAdLeftApplication() {}
@Override
public void onAdClosed() {
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}});if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();}else{}}
@Override
public void onStart() {
super.onStart();
if(mInterstitialAd.isLoaded()) {
mInterstitialAd.show();}else{}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.myapp"
android:versionCode="2"
android:versionName="1.2">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application>
</manifest>
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services-ads:+'
compile 'com.google.android.gms:play-services-ads:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Dikutip dari : http://www.sketchwarehelp.com/2017/09/how-to-integrate-admob-interstitial-ads.html?m=1
[DROID] Admob
TextView text=(TextView)findViewById(R.id.txt);
(Buton listener)
String anu="";
for(int a=1; a<10; a++){anu=anu+"text \n";}
u.setText(anu);
[DROID] perulangan for() tampil di TextView
Buatlah sebuah TextView Untuk Menampilkan Hasil Perulangan
import android. os . Bundle ;
import android. app.*;
import android. widget . TextView ;
import java . util . Timer;
import java . util . TimerTask ;
public class MainActivity extends
Activity {
private TextView tv_count ;
int angka = 0;
@Override
protected void onCreate (Bundle savedInstanceState)
{
super . onCreate(savedInstanceState );
setContentView (R . layout.main );
tv_count = (TextView ) findViewById( R . id. tex );
new Timer(). scheduleAtFixedRate ( new TimerTask ()
{
@Override
public void run () {
runOnUiThread (new Runnable() {
@Override
public void run () {
tv_count . setText ("Perulangan ke: " + angka++ );
}});}
// untuk mengatur kecepatan perulangan
}, 1000 , 1000 ); }}
[DROID] perulangan tiap detik berganti
MainActivity.java
import android.content.Intent;
import android.app.*;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
Button enableButton,disableButton;
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main); enableButton=(Button)findViewById(R.id.button1); disableButton=(Button)findViewById(R.id.button2); enableButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
startService(new Intent(MainActivity.this,
MyService.class));
}
}); disableButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
stopService(new Intent(MainActivity.this, MyService.class));
}
});
}
}
MyService.java
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
import android.media.*;
public class MyService extends Service {
MediaPlayer n;
public MyService() {
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onCreate() {
n= MediaPlayer.create(this,R.raw.owl);
Toast.makeText(this, "The new Service was Created",
Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startId) {
// For time consuming an long tasks you can launch a new thread here...
n.start();
Toast.makeText(this, " Service Started", Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
n.stop();
Toast.makeText(this, "Service Destroyed",
Toast.LENGTH_LONG).show();
}
}
main.xml
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_margin="5dp"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:textColor="#ffffff"
android:text="Stop Service" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_margin="5dp"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:textColor="#ffffff"
android:text="Start Service" />
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.myapp3" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="MyService"
android:label="Service"/>
</application>
</manifest>
[DROID] Service
MainActicity.java
import android.app.*;
import android.os.*;
import android.net.*;
import android.widget.*;
import android.content.*;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ConnectivityManager cm = (ConnectivityManager) getApplication().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnected()) {
Toast.makeText(getApplication(), "You are connected to "+netInfo.getTypeName()+" "+netInfo.getSubtypeName(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplication(), "You don't have connection.", Toast.LENGTH_SHORT).show();
}
}
}
AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
[DROID] Tes Koneksi Internet
Dialog Native
Ingin suatu halaman aplikasi muncul tapi dengan model dialog ?
Dan bisa muncul dimana saja alias muncul diluar aplikasi
Anda hanya perlu menambahkan code ini
android:launchMode="singleInstance" android:excludeFromRecents="true"android:theme="@android:style/Theme.Dialog"
Kedalam AndroidManifest.xml <activity>
Dan untuk mengatur ukuran dialog anda hanya perlu memberi ukuran yang tadinya wrap_content menjadi 500dip (contoh)
[DROID] Dialog Diluar Aplikasi
<html>
<button type="button" id="autoKlik" onclick="alert('Auto Klik Aktif setiap 50 detik')">Submit</button>
<script>
var button=document.getElementById("autoKlik");
setInterval(function(){
button.click();
}, 50000);
</script>
</html>
[WEB] membuat tombol klik otomatis setiap detik
Untuk mematikan fungsi tombol kembali anda hanya perlu menambahkan coding ini
@Override
public void onBackPressed() {
//jika ingin terjadi sesuatu ketika tombol back di klik maka buatlah fungsi di sini
}
Dan Untuk membuat Tombol Exit Gunakan Coding ini di dalam Fungsi Button
moveTaskToBack(true);
[DROID] Disable back button and create exit button
import android.app.*;
import android.os.*;
import android.widget.*;
import android.content.*;
import android.view.*;
import android.view.View.*;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);}
//seting button di xml gunakan onClick dan panggil dengan public void
//startclick adalah nilai dari onClick yang ada di Button
public void startclick ( View v){
//ketika tombol di klik maka waktu akan menghitung mundur dari 5000 (5detik) sampai 1000 (1detik)
new CountDownTimer( 5000 ,1000 ){
@Override
//jika waktu telah habis maka halaman akan berpindah
public void onFinish() {
Intent go=new Intent(hal2.this,MainActivity.class);
startActivity(go);
}
@Override
//untuk menampilkan notifikasi waktu yang sedang berhitung mundur ke dialog
public void onTick( long berhenti) {
final Dialog dialog = new Dialog(hal2.this);
dialog.setTitle("Loding"+berhenti/1000);
dialog.show();
}
}. start();
}
}