package com.ideabobo.Javascript;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.UUID;
import org.apache.cordova.CordovaActivity;
import org.json.JSONException;
import org.json.JSONObject;
import com.ideabobo.gap.MainActivity;
import com.ideabobo.gap.R;
import com.ideabobo.tool.FileTool;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.graphics.Rect;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaRecorder;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.view.Display;
public class MyObj {
public Context ctx= null;
public JSONObject json = new JSONObject();
private CordovaActivity mGap;
public MediaRecorder mRecorder;
public static String fileName = "";
private MediaPlayer mPlayer = null;
public MyObj(CordovaActivity mGap){
this.mGap = mGap;
ctx = mGap.getApplicationContext();
}
public String Test(){
return "success";
}
public void recordSound(){
String fileDir = FileTool.getSDPath()+File.separator+"qqrecord"+File.separator;
File file = new File(fileDir);
if(!file.exists()){
file.mkdirs();
}
fileName = fileDir+UUID.randomUUID()+".aac";
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(fileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
try {
mRecorder.prepare();
mRecorder.start();
} catch (IOException e){
}
}
public void stopSound(){
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
public String getRecordFile(){
return fileName;
}
public void playAudio(String path){
String fileDir = FileTool.getSDPath()+File.separator+"qqrecord"+File.separator;
String filePath = "http://192.168.31.234:8080/qqserver/upload/"+path;
mPlayer = new MediaPlayer();
mPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer arg0) {
// TODO Auto-generated method stub
mPlayer.release();
mPlayer = null;
}
});
try{
mPlayer.setDataSource(filePath);
mPlayer.prepare();
mPlayer.start();
}catch(IOException e){
Log.e("phonegap","");
}
}
@SuppressWarnings("deprecation")
public String getScreenInfo() {
Display display = mGap.getWindowManager().getDefaultDisplay();
Point outPoint = new Point();
try {
Method method = display.getClass().getMethod("getRealSize",
new Class[] { Point.class });
try {
method.invoke(display, outPoint);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONObject obj = new JSONObject();
Log.i("ScreenInfo", "invoke onCreate screenWidth: " + display.getWidth()
+ ", screenHeight: " + display.getHeight());
float aspectRatio = (float)display.getWidth() / (float)display.getHeight();
try {
obj.put("aspectRatio", aspectRatio);
obj.put("width", display.getWidth());
obj.put("height", display.getHeight());
} catch (JSONException e) {
e.printStackTrace();
}
return obj.toString();
}
/**
*
* @param activity
* @return > 0 success; <= 0 fail
*/
public int getStatusHeight(){
int statusHeight = 0;
Rect localRect = new Rect();
mGap.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
statusHeight = localRect.top;
if (0 == statusHeight){
Class<?> localClass;
try {
localClass = Class.forName("com.android.internal.R$dimen");
Object localObject = localClass.newInstance();
int i5 = Integer.parseInt(localClass.getField("status_bar_height").get(localObject).toString());
statusHeight = mGap.getResources().getDimensionPixelSize(i5);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
return statusHeight;
}
/** 显示通知栏点击跳转到指定Activity */
public void showIntentActivityNotify(String title,String note,int id){
// Notification.FLAG_ONGOING_EVENT --设置常驻 Flag;Notification.FLAG_AUTO_CANCEL 通知栏上点击此通知后自动清除此通知
// notification.flags = Notification.FLAG_AUTO_CANCEL; //在通知栏上点击此通知后自动清除此通知
// NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mGap);
//
// mBuilder.setAutoCancel(true)//点击后让通知将消失
// .setContentTitle(title)
// .setContentText(note)
// .setTicker("点我");
// //点击的意图ACTION是跳转到Intent
// Intent resultIntent = new Intent(mGap, MainActivity.class);
// resultIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// PendingIntent pendingIntent = PendingIntent.getActivity(mGap, 0,resultIntent,0);
// mBuilder.setContentIntent(pendingIntent);
// NotificationManager mNotificationManager = (NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
// Notification notif = mBuilder.build();
// mNotificationManager.notify(1, notif);
Notification notif = new Notification(R.drawable.icon, note, System.currentTimeMillis() );
notif.flags = Notification.FLAG_AUTO_CANCEL;
notif.defaults |= Notification.DEFAULT_SOUND;
notif.defaults |= Notification.DEFAULT_VIBRATE;
Intent notificationIntent = new Intent(ctx, MainActivity.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
notif.setLatestEventInfo(ctx, title, note, contentIntent);
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager)
ctx.getSystemService(ns);
mNotificationManager.notify(id, notif);
// Notification notif = new Notification(android.R.drawable.btn_star_big_on, note, System.currentTimeMillis() );
// notif.flags = Notification.FLAG_AUTO_CANCEL;
// notif.defaults |= Notification.DEFAULT_SOUND;
// notif.defaults |= Notification.DEFAULT_VIBRATE;
//
// Intent notificationIntent = new Intent(ctx, MainActivity.class);
// notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
//
没有合适的资源?快使用搜索试试~ 我知道了~
基于android平台的手机新闻客户端
共1511个文件
png:482个
svg:300个
gif:195个
需积分: 12 3 下载量 176 浏览量
2016-08-25
12:07:26
上传
评论
收藏 54.03MB ZIP 举报
温馨提示
基于android平台的手机新闻客户端
资源推荐
资源详情
资源评论
收起资源包目录
基于android平台的手机新闻客户端 (1511个子文件)
resources.ap_ 2.06MB
NewsClient.apk 2.63MB
gradlew.bat 2KB
jarlist.cache 120B
MyObj.class 9KB
GoodAction.class 7KB
Plugs.class 6KB
FileTool.class 6KB
GoodServiceImp.class 5KB
ReplayServiceImp.class 5KB
TypeServiceImp.class 5KB
ClientAction.class 5KB
UserServiceImp.class 5KB
UserAction.class 4KB
GetNowTime.class 4KB
IdeaAction.class 4KB
ReplayAction.class 3KB
CopyFile.class 3KB
User.class 3KB
BaiduLocation.class 3KB
IndexAction.class 2KB
BaiduLocation$MyLocationListener.class 2KB
Good.class 2KB
Replay.class 2KB
Page.class 1KB
MyObj$1.class 1017B
MainActivity.class 1010B
Type.class 988B
ReplayService.class 703B
GoodService.class 683B
UserService.class 548B
TypeService.class 548B
R.class 471B
R$string.class 466B
R$drawable.class 421B
R$xml.class 381B
BuildConfig.class 341B
R$attr.class 334B
.classpath 1KB
.classpath 475B
org.eclipse.wst.common.component 477B
org.eclipse.wst.jsdt.ui.superType.container 49B
jquery.mobile.min.css 216KB
jquery.mobile-1.4.5.min.css 203KB
jquery.mobile-1.4.5.min.css 203KB
jquery.mobile-1.4.3.min.css 202KB
jquery.mobile-1.4.3.min.css 202KB
jquery.mobile.flatui.css 163KB
jquery.mobile.flatui.css 163KB
jquery.mobile.flatui.css 163KB
theme-classic.css 67KB
theme-classic.css 67KB
easyui.css 34KB
easyui.css 34KB
easyui.css 34KB
easyui.css 32KB
easyui.css 32KB
easyui.css 29KB
datagrid.css 5KB
datagrid.css 5KB
datagrid.css 5KB
datagrid.css 4KB
datagrid.css 4KB
datagrid.css 4KB
tabs.css 4KB
tabs.css 4KB
tabs.css 4KB
tabs.css 4KB
tabs.css 4KB
tree.css 4KB
tree.css 4KB
tree.css 4KB
tree.css 4KB
tree.css 4KB
tree.css 4KB
tabs.css 3KB
calendar.css 3KB
calendar.css 3KB
calendar.css 3KB
calendar.css 3KB
calendar.css 3KB
calendar.css 3KB
default.css 2KB
panel.css 2KB
panel.css 2KB
panel.css 2KB
all.css 2KB
panel.css 2KB
panel.css 2KB
layout.css 2KB
layout.css 2KB
panel.css 2KB
layout.css 2KB
layout.css 2KB
linkbutton.css 2KB
layout.css 2KB
layout.css 2KB
linkbutton.css 2KB
linkbutton.css 2KB
linkbutton.css 1KB
共 1511 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论
qq_19341435
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功