To develop this app, you will need to create an Android project in Eclipse. The name of the project or application will be BClean. The BClean app has the simple user interface. When the app firstly launches, it displays a list of browser history and bookmarks. You will need to edit the activity_main.xml file to include a ListView component. Here is the content of the activity_main.xml file.
activity_main.xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ListView
android:id="@+id/hb_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</RelativeLayout>
Each item of the list will display three fields of each browser history or bookmark. The first field is the icon. The second field is the title and the third field is the url.
To customize the ListView component to allow each row or item to show the data in that way, you will need the listlayout.xml and ListAdapterModel.java files. The listyout.xml file represents the layout of each row or item of the list. There are three components in the listlayout file. The first component is an ImageView. It is for displaying the icon. The second and third components are TextView compoennts for displaying the title and url.
listlayout.xml file
<?xml version="1.0" encoding="utf-8"?>
<!-- Single List Item Design -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<ImageView
android:id="@+id/icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:padding="5sp"
android:contentDescription="icon_image"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/hbtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1sp"
android:textSize="20sp"
android:scrollHorizontally="true"
android:singleLine="true"
android:textStyle="bold" >
</TextView>
<TextView
android:id="@+id/hburl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1sp"
android:textSize="15sp"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="#0000ff">
</TextView>
</LinearLayout>
</LinearLayout>
ListAdapterModel. java file
package com.example.bclean;
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Bitmap;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class ListAdapterModel extends ArrayAdapter<String>{
int groupid;
ArrayList<String> titles;
ArrayList<String> urls;
ArrayList<Bitmap> bitmaps;
Context context;
String path;
public ListAdapterModel(Context context, int vg, int id, ArrayList<String> titles,ArrayList<String> urls,ArrayList<Bitmap> bitmaps){
super(context,vg, id, titles);
this.context=context;
groupid=vg;
this.titles=titles;
this.urls=urls;
this.bitmaps=bitmaps;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(groupid, parent, false);
ImageView imageView = (ImageView) itemView.findViewById(R.id.icon);
imageView.setImageBitmap(bitmaps.get(position));
TextView textTitle= (TextView) itemView.findViewById(R.id.hbtitle);
String title=titles.get(position);
textTitle.setText(title);
TextView textURL = (TextView) itemView.findViewById(R.id.hburl);
String url=urls.get(position);
textURL.setText(url);
//make the url clickable
Linkify.addLinks(textURL, Linkify.ALL);
return itemView;
}
}
In the onCreate method of the MainActivity class, three ArrayList objects are created by calling the createLists method. One ArrayList object is to store the titles of the browser history and bookmarks. One is for storing the urls. And the last one will store the icons. The three ArrayList objects will be supplied to the ListAdapterModel class to show the browser history and bookmarks on the list.
MainActivity.java file
package com.example.bclean;
import java.util.ArrayList;
import android.os.Bundle;
import android.provider.Browser;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends Activity {
private ArrayList<String> titles;
private ArrayList<String> urls;
private ArrayList<Bitmap> bitmaps;
private ContentResolver cr;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
createLists();
}
protected void onResume(){
super.onResume();
getBH();
showHistoryBookmarks();
}
public void createLists(){
titles=new ArrayList<String>();
urls=new ArrayList<String>();
bitmaps=new ArrayList<Bitmap>();
}
public void getBH(){
Bitmap icon;
cr=getContentResolver();
String order=Browser.BookmarkColumns.DATE+" DESC";
String[] projection={Browser.BookmarkColumns.TITLE,Browser.BookmarkColumns.URL,Browser.BookmarkColumns.FAVICON};
//String selection=projection[0]+"=?";
//String args[]={"Google"};
Cursor rows=cr.query(Browser.BOOKMARKS_URI,projection, null,null,order);
if(rows.getCount()>0){
while(rows.moveToNext()) {
//read title
String title=rows.getString(rows.getColumnIndex(projection[0]));
//read url
String url=rows.getString(rows.getColumnIndex(projection[1]));
//read icon
byte[] bicon=rows.getBlob(rows.getColumnIndex(projection[2]));
if(bicon!=null){
//convert blob image data to Bitmap
icon=BitmapFactory.decodeByteArray(bicon,0,bicon.length);
}
else{
//default icon for history and bookmarks that do not icons
icon=BitmapFactory.decodeResource(getResources(),R.drawable.noicon);
}
//add to lists
addToList(title,url,icon);
}
//close the cursor
rows.close();
}
}
public void addToList(String title,String url, Bitmap bitmap){
titles.add(title);
urls.add(url);
bitmaps.add(bitmap);
}
public void showHistoryBookmarks(){
ListView l=(ListView) findViewById(R.id.hb_list);
if(l!=null){
if(titles.size()>0){
ListAdapterModel aa=new ListAdapterModel(this,R.layout.listlayout,R.id.hbtitle,titles,urls,bitmaps);
l.setAdapter(aa);
}
else{
Toast.makeText(this, "This is no bookmark or history.", Toast.LENGTH_SHORT).show();
}
}
}
public void cleanHB(){
if(Browser.canClearHistory(cr)){
Browser.clearHistory(cr); //clear history data
createLists(); //recreate the lists
onResume(); //update the list
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item){
if(item.getItemId()==R.id.action_clean)
{
cleanHB();
}
return false;
}
}
The title, and urls are text (string). The icon field is of Blob type. The data in Blob type can be converted to the Bitmap by using the decodeArrayByte method of the BitmapFactory class.
The showHistoryBookmarks will be called after the getHB method to display the titles, urls, and icons of the browser history and bookmarks on the list. In this method, the ListAdapterModel object is created and the titles, urls, and icons are passed to it.
The cleanHB method is called when the user touches the clean menu item. It will remove all history data from Android. The list will be updated to reflect the change by calling the onResume method. You will need to edit the main.xml file (in menu folder) to add the clean item to the menu. Here is the content of the main.xml file.
main.xml file
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_clean"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_clean"/>
</menu>
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" />
Download the apk file of the BClean app
Great post, thanks!!
ReplyDeleteCan you let me know how to add date and time stamps?
also how to export the browser history list to a text file on the sd card?
Adam
Ok i have managed to get the date/time stamp in the list. But now instead of exporting this list to SD card, is there any way to send this list automatically via email at a scheduled time?
DeleteHow to add date&time stamp in the list?
DeleteGreat Post!!!!
ReplyDeleteThanks for your valuable posting, it was very informative. Am working in Erp Software Company In India
does it takes browser history and bookmarks from all the browsers like chrome,mozilla,ucbrowser etc
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteVương Lâm nói tên ra, thiếu niên nghe xong, nhất thời ngạc nhiên, thất thanh nói:
ReplyDelete- Ngươi chính là Vương Lâm hả, phế... kia dựa vào tự sát mới tiến vào Hằng Nhạc Phái.
Nói đến đây, hắn cảm thấy ngượng, cười nhẹ nói:
- Bạn hữu, ta gọi là Trương Hổ, đừng để trong lòng, hiện tại trong phái hầu như không ai là không biết ngươi, ngươi cũng đừng trách ta vừa rồi nói như vậy, thực ra ta rất bội phục ngươi, lại có thể sử dụng như vậy phương pháp tiến vào.
học kế toán thực hành
forum rao vặt cattleya
học kế toán tổng hợp
chung cư eco-green-city
học kế toán thực hành
học kế toán tại bắc ninh
dịch vụ kế toán trọn gói
chung cư hà nội
dịch vụ làm báo cáo tài chính
kế toán cho quản lý
khoá học kế toán thuế
keny idol
trung tâm kế toán tại long biên
trung tâm kế toán tại hải phòng
Vương Lâm cười khổ, cũng không thanh minh, lại đưa qua mấy củ khoai lang.
Trương Hổ vội vàng tiếp nhận, sau ăn mấy khẩu ngượng ngùng nói:
- Vương Lâm, ngươi vẫn là chừa cho mình chút đi, ngươi mới tới đây, không biết con chồn tạp vụ ở đây trong lòng tâm địa gian xảo, chờ ngày mai ngươi làm việc sẽ biết rõ, con mẹ nó, hắn quả thực sẽ không nhìn những đệ tử ký danh chúng ta như con người!
Chương 11: Trương Hổ
- Con chồn?
Vương Lâm giật mình, người thứ nhất hắn nghĩ đến chính là người thanh niên áo vàng lúc trước cười nhạo mình, cảm thấy hắn có vẻ phù hợp với danh hiệu này, nhưng trong lòng không biết rốt cuộc đối phương nói có đúng là hắn ta hay không.
- A? Ngươi chưa nhìn thấy hắn? Chính là thằng cha phụ trách an bài công tác của ký danh đệ tử, hắn cũng là ký danh đệ tử, chẳng qua đã đạt được tư cách tu luyện tiên pháp, mặc áo vàng, vừa nhìn đã thấy không phải là người tốt gì, giống như một con chồn con, chúng ta thường ở đằng sau vụng trộm gọi hắn như vậy.
Trương Hổ nuốt nước miếng, nghiến răng nghiến lợi giải thích.
Cút đi
DeleteWhen I enter this source code on Android Studio it does some errors
ReplyDeleteI always like and search such topics and everything connected to them.Excellent and very cool idea and the subject at the top of magnificence ..
ReplyDeleteWeblogic Training in Chennai
why it shows only local history? how to show full history from google acount ?
ReplyDeleteYour post, regarding Android App Development is very effective for learners. I have got some important suggestions from it. I'm working in Brave Technologies Private Limited.BRAVE TECHNOLOGIES is a leading ERP software company offering best quality cost effective software applications and end to end enterprise solutions. We are experts in Mobile App development on both platforms – Android & iOS.
ReplyDeleteHello, Thanks for this valuable post. It's working fine in Android 4.0.1 version. Not working with greater then android 4.1 version. Can you suggest me how to get browser history for Android 5.0 or greater than this.
ReplyDeleteHello. Do you know how to get the history and bookmarks option in case of an Android Dictionary App... that has an option to access the history of the recently searched words and also an option to bookmark a particular word for quick access?
ReplyDeleteI am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.
ReplyDeleteMobile App Development Company
Mobile App Development Company in India
Mobile App Development Companies
problems with BookmarkColumns...help pls
ReplyDeleteYour Error is the same of what i got my project have you reach on solution and share with me
DeleteThank you for your precious information. very clear explanation.Please share more like that..
ReplyDeleteConstruction Services
I have learnt quite a lot about creating a simple Android app to view browser history and bookmarks by reading this post. Many thanks for sharing this invaluable information. Feel free to click on Professional Writing Services | Writing Academic Papers
ReplyDeleteHello Admin I have tried to build this history project through all the steps you share us but when i reach on in MainActivity GiHB method >> BookmarkColumns it show me an error may you help me to fix this
ReplyDeleteAmazing Article ! I have bookmarked this article page as i received good information from this. All the best for the upcoming articles. I will be waiting for your new articles. Thank You ! Kindly Visit Us @ Coimbatore Travels | Ooty Travels | Coimbatore Airport Taxi | Coimbatore taxi | Coimbatore Taxi
ReplyDeletehi nice sites...
ReplyDeleteMerkez Bankası Bağımsızlığı
Üniversite Capsleri
hediyelik eşya
Excellent info on latest technologies. Looking for software courses?
ReplyDeletePHP Training in Chennai
web designing course in chennai
JAVA Training in Chennai
Hadoop Training in Chennai
Selenium Training in Chennai
German Classes in chennai
java training in OMR
I love it... I've never tried the texture paste before but now I will. Love the numbers!
ReplyDeleteI love this post.
ReplyDeleteโปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
เพียงแค่คุณสมัคร Gclub กับทางทีมงานของเราเพียงเท่านั้น
ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
สมัครสล็อตออนไลน์ >>> goldenslot
สนใจร่วมลงทุนกับเรา สมัครเอเย่น Gclub คลิ๊กได้เลย
Nice blog. keep posting. Loved it very much
ReplyDeleteserviced offices manila
virtual office metro manila
virtual office makati
virtual office manila
office for rent in makati
Really helpful
ReplyDeleteWeb Development Company in Canada
mobile gaming development vancouver
website development toronto
web development vancouver
Great post very informative thanks for sharing.
ReplyDeletehttps://www.skyhidev.com/website-development-vancouver/
I appreciate your effort and want you to keep on posting such posts
ReplyDeleteAndroid internship in kochi
Wow what a Great Information about World Day its incredibly charming instructive post. An obligation of appreciation is all together for the post.
ReplyDeletewhat is marketing, link building strategies, on-page seo best practices, balanced scorecard for marketing management, what is sales, is desire to buy emotional or rational decision, how i increased website traffic by 600 in 24 months, free internet marketing resources, free digital marketing resources
This comment has been removed by the author.
ReplyDeleteI loved the way you explained the stuff.
ReplyDeleteecommerce website development vancouver
Thank you for sharing in this article Great extra tips i am working in a Website Development Company Vancouver
ReplyDeleteThank you for the information you provide, it helped me a lot! it's great
ReplyDeleteios development course in kochi
Great Post!
ReplyDeleteHire PHP Developer
Hire PHP Developer
Hire JS Developer
Hire WordPress Developer
Hire Laravel Developer
Hire Magento Developer
Php Internship in Kochi
IT Consulting Services in Kochi
Nice blog. keep posting. Loved it very much
ReplyDeleteExpense Management System
Invoice Management System
HRM System
Student Management System
Fleet Maintenance software
Stock Management System
Rental Management System
Prior to stumbling upon this post, I didn't know that creating an Android app to view browser history and bookmarks can be that simple. Thanks a lot for sharing this information. Feel free to click on Professional Marketing Company. We assure you that once you click on that link, you will get online marketing services that will meet if not surpass your expectations.
ReplyDeleteYour blog posts are more interesting and impressive. I think there are many people like and visit it regularly, including me.I actually appreciate your own position and I will be sure to come back here.
ReplyDeleteecommerce development company in kochi
well written article. I’ll be sure to bookmark it and return to read more of your useful info. Thanks for the post. I will definitely return.
ReplyDeletewebsite development company in kochi
This comment has been removed by the author.
ReplyDeleteIts very best of best content and, I learn some thing very complicated on different blogs everyday. I think You put a lot of effort to create this topic blog. I appreciate your work and, thank you so much for this sharing. best assignment help -
ReplyDeleteplagiarism checker -
assignment writing help
Striking to take a gander at your blog once more, it's been an especially drawn out time period for me. I need this article to complete my school task. Appreciative to you. The user is 24 * 7 available on affected devices. Check the simple solution if there is Hp Error Code oxc19a0003.
ReplyDeleteThis is the kind of article information to read whenever you want to understand more about outsourcing. Personally, I have really benefited and so marvelous from reading it. I can’t wait to read more of your new content. Thanks for sharing and Good luck for new updates. taxation law assignment help -
ReplyDeletecorporate finance assignment help -
nursing assignment help
While utilizing the printer in the event that it stalls out in the center of the work, it can raise the temper of the user. We have seen numerous canon putting their questions dependent on canon printer in error state issue, for instance what do I do if my standard printer is in error state?, how would I get my ordinance printer out of error state, etc. Subsequently, to settle every one of these inquiries we have the arrangement and it is referenced beneath.
ReplyDeletecanon printer in error state
This is very very helpful content information for all of everyone. Thank you very much for sharing this very superb topic share with us. You should take part in a contest for one of the most useful sites online. I’m going to highly recommend this website all articles! Thanks. assignment provider -
ReplyDeletehealthcare management assignment help -
childcare assignment help
Hi there very nice website!! Guy .. Excellent .. Amazing ..
ReplyDeletemobile app development company in saudi arabia
Great post I like it very much keep up the good work.
ReplyDeleteCardboard packaging wholesale
wholesale Cosmetic packaging
Great post!
ReplyDeletehttps://globosoft.in/gKart-complete-ecommerce-solution
https://globosoft.in/
I am so grateful for your blog.Thanks Again
ReplyDeleteMobile app development companies in Saudi Arabia