private static void readExif(RandomAccessFile raf, int offset) throws IOException{
raf.seek(12+offset);
short entries = raf.readShort();
System.out.println(String.format("IFD entries = %d", entries));
for(short i=0; i<entries; i++){
short tag = raf.readShort();
short type = raf.readShort();
int count = raf.readInt();
int offsetOrValue = raf.readInt();
System.out.println(String.format("tag = %x type = %x count = %d offsetOrvalue = %d", tag, type, count, offsetOrValue));
long currPointer = raf.getFilePointer();
if(tag==-30871){
raf.seek(12+offsetOrValue);
short entries2 = raf.readShort();
for(short j=0; j<entries2; j++){
short tag2 = raf.readShort();
short type2 = raf.readShort();
int count2 = raf.readInt();
int offsetOrValue2 = raf.readInt();
System.out.println(String.format("tag = %x type = %d count = %d offsetOrvalue = %d", tag2, type2, count2, offsetOrValue2));
long currPointer2 = raf.getFilePointer();
if(tag2==-28669){
raf.seek(12+offsetOrValue2);
byte[] bb = new byte[count2];
raf.read(bb);
System.out.println("DateTimeOriginal = "+new String(bb));
raf.seek(currPointer2);
}
}
raf.seek(currPointer);
}
}
int nextOffset = raf.readInt();
if(nextOffset>0)
readExif(raf, nextOffset);
}
public static void main(String args[]) {
try {
RandomAccessFile raf = new RandomAccessFile(new File("D:\\Archive\\MyPhotosAndVideos\\IMG_20140920_130624.jpg"), "r");
raf.seek(12);
raf.readShort();
raf.readShort();
readExif(raf, raf.readInt());
raf.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Document getDocument(String url) throws MalformedURLException,
IOException, Exception {
URL documentUrl = new URL(url);
URLConnection conn = documentUrl.openConnection();
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document;
InputStream stream = null;
try {
stream = conn.getInputStream();
document = builder.parse(stream);
} finally {
if (stream != null)
stream.close();
}
return document;
}
Log.i("MyLog", "firstParam=" +((VremActivity )this.getParent()).getFirstParam());
Intent myIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(myIntent, 1);
Intent myIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(myIntent, 1);
org.jsoup
Interface Connection
To get a new Connection, use Jsoup.connect(String).
header(String name, String value)
Set a request header.
data(String key, String value)
Add a request data parameter.
method(Connection.Method method)
Set the request method to use, GET or POST.
try {
Connection conn = Jsoup
.connect("http://4pda.ru/forum/index.php?act=Login&CODE=01");
conn.data("PassWord", "password");
conn.data("UserName", "username");
conn.method(Connection.Method.POST);
conn.referrer("http%3A%2F%2F4pda.ru%2Fforum%2Findex.php%3F");
Response resp = conn.execute();
System.out.println("statusCode: " + resp.statusCode());
Document doc = conn.url("http://4pda.ru/forum/index.php?").get();
System.out.println(doc.select("div.user_home").text());
} catch (IOException e) {
e.printStackTrace();
}
...
Process logcatProc = Runtime.getRuntime().exec("adb logcat -v time -b radio GSM:D *:S");
BufferedReader mReader = new BufferedReader(new InputStreamReader(logcatProc.getInputStream()), 1024);
...
[GSMConn] onConnectedInOrOut: connectTime=1364194745375
[GSMConn] onDisconnected: cause=LOCAL
Ковырять нужно /system/framework/android.policy.jar, именно там происходит обработка.
Вооружаться dex2jar, JDGUI, APKTools для декомпиляции и анализировать код.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
public class LockService extends Service {
PowerManager.WakeLock wl;
WindowManager mWindowManager;
boolean isShowing;
View mView;
Thread mThread;
BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_SCREEN_ON)) {
if (isShowing) {
if ((mThread == null)
|| ((mThread != null) && (!mThread.isAlive())))
mThread = new Thread() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(1000);
mWindowManager.removeView(mView);
isShowing = false;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
mThread.start();
}
}
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
if (!isShowing) {
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FILL_PARENT,
WindowManager.LayoutParams.FILL_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
|
// Draws over status bar
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
mWindowManager.addView(mView, params);
isShowing = true;
}
}
}
};
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
mView = new View(this);
mView.setBackgroundColor(Color.BLACK);
mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"com.google.syncloc.SyncLocService");
wl.acquire();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
//intentFilter.addAction(Intent.ACTION_USER_PRESENT);
intentFilter.setPriority(999);
registerReceiver(mReceiver, intentFilter);
super.onCreate();
}
@Override
public void onDestroy() {
if (isShowing)
mWindowManager.removeView(mView);
if ((mThread != null) && (mThread.isAlive()))
mThread.interrupt();
wl.release();
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
}