We rightly combat the feelings that tell us, "I need to get cleaned up before I come to God" and "I just need to get a little better before I return to Him." The truth is that we need only to turn to God and trust that He welcomes us. He is a Father Who comes running as soon as He sees that we have turned from our rebellion and are heading towards Him. (Luke 15:20)
But we should not swing too far in the other direction and imply that there are no conditions whatsoever to being heard in prayer. As wrong as it is to say, "you need to get your act together before coming to God," it's also equally wrong to say, "as soon as you pray, God definitely listens to you." 
The Bible repeatedly emphasizes certain characteristics which determine whether God will hear our prayers, and teaches that if we lack these characteristics, we are in danger of not being heard. I would like to examine some of the reasons why God may not hear our prayers over a short series of blog posts. 
The first reason I'd like to highlight is our refusal to acknowledge sin. Unconfessed or ignored sin is incredibly dangerous to our spiritual lives, and if we try to pray to God while ignoring the sin in our lives, we may be surprised to find that God is not listening one bit! It can seem like quite an offensive idea to say that God refuses to listen to us, and it may actually be completely opposite to some views of the nature of God, so it is good to look to the Bible to examine what God has said about prayer. I'd like to point to a few passages which show God isn't perpetually in a state of being willing to listen, regardless of the condition of the petitioner. These are but a few examples -- the Lord willing, we will highlight more in the months to come -- that focus specifically on this first reason, that of ignoring sin:
“"What are your multiplied sacrifices to Me?" Says the LORD. "I have had enough of burnt offerings of rams And the fat of fed cattle; And I take no pleasure in the blood of bulls, lambs or goats. "When you come to appear before Me, Who requires of you this trampling of My courts? "Bring your worthless offerings no longer, Incense is an abomination to Me. New moon and sabbath, the calling of assemblies- I cannot endure iniquity and the solemn assembly. "I hate your new moon festivals and your appointed feasts, They have become a burden to Me; I am weary of bearing them. "So when you spread out your hands in prayer, I will hide My eyes from you; Yes, even though you multiply prayers, I will not listen. Your hands are covered with blood. "Wash yourselves, make yourselves clean; Remove the evil of your deeds from My sight. Cease to do evil,”
‭‭Isaiah‬ ‭1:11-16‬ ‭NASB‬‬
God says something similar to Solomon after he builds the temple, teaching how the people can be sure that He will hear their prayers:
“and (if) My people who are called by My name humble themselves and pray and seek My face and turn from their wicked ways, then I will hear from heaven, will forgive their sin and will heal their land.
‭‭2 Chronicles‬ ‭7:14‬ ‭NASB‬‬
These two passages demonstrate that God's willingness to hear from heaven has to do with the condition of those who are praying. Specifically they show how ignoring unconfessed sin shuts God's ears to our prayers. There's a story in 2 Chronicles 34 about Josiah that gives a similar message, and demonstrates the difference of God's attitude towards those who meet His conditions from the attitude He has towards those who ignore their sin. The entire passage is well worth meditating upon, as the last verse (quoted below) is especially wonderful in the context of the story. But to give a brief recap: the priest finds the book of the law while cleaning the temple; he realizes it's quite a discovery, so he has the book read in the presence of Josiah, the king; when the king hears the law being read, he is greatly disturbed to learn that Israel has neglected to perform all of God's commands; Josiah asks the scribe to inquire whether God is displeased on his behalf; God confirms Josiah's fear, that He is greatly displeased with His people because they had forsaken Him and is ready to pour out His wrath upon them; but regarding Josiah, the Lord says the following: 
Because your heart was tender and you humbled yourself before God when you heard His words against this place and against its inhabitants, and because you humbled yourself before Me, tore your clothes and wept before Me, I truly have heard you," declares the LORD. (‭2 Chronicles‬ ‭34‬:‭27‬ NASB)
Josiah's tenderness and broken-heartedness enabled the Lord to truly listen to his prayer. Even though the people were guilty of forsaking God's commandments (Josiah included!), because Josiah was deeply and truly repentant upon learning of his sin, God dealt with him uniquely and showed him mercy, despite the fact that He was ready to pour out His wrath on the rest of the people.
One last example from the Bible sheds light on how we can be sure that God will hear our prayers:
If I regard wickedness in my heart, the Lord would not hear; but certainly God has heard; He has given heed to the voice of my prayer. Blessed be God, Who has not turned away my prayer nor His lovingkindess from me.
(‭Psalms‬ ‭66‬:‭18-20‬ NASB)
What David says here is that he is confident that God heard his prayer because he was conscientious to confess his sin! Any sin that he saw, he did not "regard" (or "put up with it," as we might say), but confessed it, trusting God to forgive. (Psalm 32:5) This is consistent with the passages we've already seen, that God's willingness to hear our prayers isn't unconditional. There are some things we need to do, characteristics that should be present, for us to be sure that He will listen. In light of this first reason that God might not listen to our prayers, what should we do? If we combine the passages referenced here, the instruction might sound something like this: 

"Confess your sin! Don't let any of it stand in your conscience without confessing it and getting rid of it! Allow your heart to be broken because of the price God had to pay to forgive you! Sin sent Jesus to the cross, and it is the cause of your present separation. Humble yourself before God, trusting Him to forgive, and seek to hate sin as much as He does. Don't put up with it, don't desire it, don't play the fool with it. Sin is your biggest problem, and acting like it's not there keeps you from receiving anything else you might ask for."
Confessing sin before we ask anything of God demonstrates that we are more concerned about His demands than our needs, that any unconfessed iniquity weighs on us more than any pressing concern in our lives. Taking sin seriously, confessing it as we see it, and having a desperate desire to be rid of it, is the first step to growing in confidence that God will listen when we pray.
We should not be at all reluctant to confess, because of the wonderful promise in God's Word that, 
If we confess our sins, He is faithful and righteous to forgive us our sins and to cleanse us from all unrighteousness.
‭‭1 John‬ ‭1:9‬ ‭NASB‬‬
There is wonderful freedom and blessing in interacting with our Father as one who has been completely cleansed of all unrighteousness!