给别人做个广告联盟,要给开发者提供一个sdk,然后集成到他们的应用中,在开发的过程中遇到了很多问题,再此记录一下:
1.代码创建webview很简单:
private WebView webView;
webView = new WebView(this);
webView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT))
2.把一些图片资源放入到assets,然后可以一起打入jar包,访问的方法为:
private static Bitmap getImageFromAssetsFile(String fileName)
{
Bitmap image = null;
AssetManager am = activity.getResources().getAssets();
try
{
InputStream is = am.open(fileName);
image = BitmapFactory.decodeStream(is);
is.close();
}
catch (IOException e)
{
e.printStackTrace();
}
return image;
}
3.定义一个ImageButton
ImageButton ib2 = new ImageButton(activity);
ib2.setId(3);
ib2.setImageBitmap(getImageFromAssetsFile("haoqi_btn_cancle.jpg"));
ib2.setBackgroundColor(Color.TRANSPARENT); //设置透明
4.混淆,用的sdk\tools\proguard\bin\proguardgui.bat 对jar进行的混淆
主要做的配置就是:[shrinking]步中设置了一下keep:
android.app.Activity
android.app.Service
public method